queue

Filling a queue and managing multiprocessing in python

血红的双手。 提交于 2019-12-17 06:09:49
问题 I'm having this problem in python: I have a queue of URLs that I need to check from time to time if the queue is filled up, I need to process each item in the queue Each item in the queue must be processed by a single process (multiprocessing) So far I managed to achieve this "manually" like this: while 1: self.updateQueue() while not self.mainUrlQueue.empty(): domain = self.mainUrlQueue.get() # if we didn't launched any process yet, we need to do so if len(self.jobs) < maxprocess: self

How do I make and use a Queue in Objective-C?

柔情痞子 提交于 2019-12-17 04:39:58
问题 I want to use a queue data structure in my Objective-C program. In C++ I'd use the STL queue. What is the equivalent data structure in Objective-C? How do I push/pop items? 回答1: Ben's version is a stack instead of a queue, so i tweaked it a bit: NSMutableArray+QueueAdditions.h @interface NSMutableArray (QueueAdditions) - (id) dequeue; - (void) enqueue:(id)obj; @end NSMutableArray+QueueAdditions.m @implementation NSMutableArray (QueueAdditions) // Queues are first-in-first-out, so we remove

input size of a queue by the user

你。 提交于 2019-12-14 04:06:29
问题 i was trying to learn array implementation of a queue in the given code #include <stdio.h> main() { int q[10]={0}, i, front=-1, rear=-1, max=10, n, item; printf("\n" "\tMENU\n" "1.ENQUEUE\n" "2.DEQUEUE\n" "3.DISPLAY\n" "4.EXIT\n" ); do { printf("\nEnter your choice\n"); scanf("%d",&n); switch(n) { case 1: if(rear<max-1) // .............so on they have not asked user to input size of the queue but already defined it as 10.Is it only for this case or should we always define it and not give user

Queuing tasks in asp.net core

孤街浪徒 提交于 2019-12-14 03:52:52
问题 E.g. of functionality There is 20 users and they clicked send button almost in one time, so methods stacking in queue and first user message is sent and response received, after second third and so on. Users wont chat with other people but with device which response is pretty fast So I am trying to queue Task which sends Message. I found code samples that uses Task queuing as shown in Example 1 and Example 2 . Example 1 public class SerialQueue { readonly object _locker = new object();

Android RequestQueue not initialized

倖福魔咒の 提交于 2019-12-14 03:24:15
问题 I am new to android and currently I want to develop an application that need to request network using volley. However, it returns error below: Caused by: java.lang.IllegalStateException: RequestQueue not initialized at com.myapp.zeptomobile.myapp.app.StaggeredDemoApplication.getRequestQueue(StaggeredDemoApplication.java:35) at com.myapp.zeptomobile.myapp.FlickrActivity.onCreate(FlickrActivity.java:75) at android.app.Activity.performCreate(Activity.java:5248) at android.app.ActivityThread

Why i need cancel tasks in this queue example?

旧城冷巷雨未停 提交于 2019-12-14 03:02:18
问题 Well I am looking into python documentation for study for my work. I am new to python and also programming, I also do not understand concepts of programming like async operations very well. I usign Fedora 29 with Python 3.7.3 for try examples of queue and the lib asyncio. Follow the example of queue and async operations below: import asyncio import random import time async def worker(name, queue): while True: # Get a "work item" out of the queue. sleep_for = await queue.get() # Sleep for the

Working out the SQL to query a priority queue table

痴心易碎 提交于 2019-12-14 00:17:12
问题 I am implementing a small queue to handle which process gets to run first. I am using a table in a database to do this. Here is the structure of the table (I'm mocking it up in SQLite): "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "identifier" VARCHAR NOT NULL , "priority_number" INTEGER DEFAULT 15, "timestamp" DATETIME DEFAULT CURRENT_TIMESTAMP, "description" VARCHAR I am trying to write SQL to give me the row of which process can run next. Here is some sample data: id identifier

QNX pthread_mutex_lock causing deadlock error ( 45 = EDEADLK )

爷,独闯天下 提交于 2019-12-13 20:43:26
问题 I am implementing an asynchronous log writing mechanism for my project's multithreaded application. Below is the partial code of the part where the error occurs. void CTraceFileWriterThread::run() { bool fShoudIRun = shouldThreadsRun(); // Some global function which decided if operations need to stop. Not really relevant here. Assume "true" value. while(fShoudIRun) { std::string nextMessage = fetchNext(); if( !nextMessage.empty() ) { process(nextMessage); } else { fShoudIRun =

Deserializing abstract Queue<T> in Json [duplicate]

末鹿安然 提交于 2019-12-13 20:22:24
问题 This question already has an answer here : Deserialize a List<AbstractClass> with newtonsoft.json (1 answer) Closed 4 years ago . I have a Queue of an abstract class KVP. I queue 2 different objects which inherit from KVP. Everything works fine when I serialize the queue, but since KVP cannot be constructed it fails on deserialization. If it was a single non generic object I could deserialize as dynamic, but I'm not sure how to deserialize a queue that could hold both events and IDs. Sample

Data Structure for Queue using Map Implementations in Java with Size limit of 5

强颜欢笑 提交于 2019-12-13 19:17:27
问题 I have map with some records. I want to restrict that map to only 5 elements and whenever a new element is added the first item should be removed and new element should be added in last position of map. Something similar to FIFO. Can anyone please suggest me a data structure to use or the solution itself. E.g : Map<String,String> map=new LinkedHashMap<String,String>(5); for(int i=0;i<5;i++){ map.put(i+"",i+""); } map.put("5","5"); /* should remove map.get(0) and map.size will be still 5