queue

Queuing promises

空扰寡人 提交于 2019-12-18 13:27:59
问题 I use mbostock/queue for queuing few async operation. It is more to rate limit (UI generate few events, where the backend can process it slowly), and also to make sure they are processed sequentially. I use it like function request(d, cb) { //some async oper add.then(function(){ cb(null, "finished ") }) } var addQ = queue(1); addQ.defer(request) //called by few req at higher rates generated by UI I already uses angular.js $q for async operation. So, do I have to use mbostock/queue , or can I

Is there a FIFO stream in Scala?

对着背影说爱祢 提交于 2019-12-18 12:58:06
问题 I'm looking for a FIFO stream in Scala, i.e., something that provides the functionality of immutable.Stream (a stream that can be finite and memorizes the elements that have already been read) mutable.Queue (which allows for added elements to the FIFO) The stream should be closable and should block access to the next element until the element has been added or the stream has been closed. Actually I'm a bit surprised that the collection library does not (seem to) include such a data structure,

Android: intentservice, how abort or skip a task in the handleintent queue

社会主义新天地 提交于 2019-12-18 12:17:33
问题 i have an activity ("ApplicationActivity") that call an intent service ("DownloadService") The intentService download files from internet in background, but i want to be able to abort a specific download......... So let's say that i put 5 files in queue: file 1,2,3,4,5 The intent service start downloading the number 1, then the second and so on.... 1) Is there a way to say to the intent service abort what you are doing at the moment in the method handle event (in this case downloading file 1)

c# stack queue combination

删除回忆录丶 提交于 2019-12-18 12:09:44
问题 is there in C# some already defined generic container which can be used as Stack and as Queue at the same time? I just want to be able to append elements either to the end, or to the front of the queue thanks 回答1: Check the LinkedList class. LinkedList<int> list = new LinkedList<int>(); list.AddFirst(1); list.AddLast(2); list.AddFirst(0); 回答2: Here's my implementation of an immutable deque : http://blogs.msdn.com/ericlippert/archive/2008/02/12/immutability-in-c-part-eleven-a-working-double

Messaging, Queues and ESB's - I know where I want to be but not how to get there

徘徊边缘 提交于 2019-12-18 11:59:56
问题 To cut a long story short, I am working on a project where we are rewriting a large web application for all the usual reasons. The main aim of the rewrite is to separate this large single application running on single server into many smaller decoupled applications, which can be run on many servers. Ok here's what I would like: I would like HTTP to be the main transport mechanism. When one application for example the CMS has been updated it will contact the broker via http and say "I've

Delphi thread that waits for data, processes it, then resumes waiting

China☆狼群 提交于 2019-12-18 11:56:35
问题 I need to create a thread in Delphi with the following characteristics: Waits until the main thread adds data to a shared queue. Processes all the data in the queue, returning the results to main thread (for this last part I'll just send messages to the main window). Processing is time-consuming, so new data may be added to the queue while the worker thread is processing previous entries. Resumes waiting, using as little cpu cycles as possible. I cannot send messages to the thread, since it

Dumping a multiprocessing.Queue into a list

妖精的绣舞 提交于 2019-12-18 11:04:32
问题 I wish to dump a multiprocessing.Queue into a list. For that task I've written the following function: import Queue def dump_queue(queue): """ Empties all pending items in a queue and returns them in a list. """ result = [] # START DEBUG CODE initial_size = queue.qsize() print("Queue has %s items initially." % initial_size) # END DEBUG CODE while True: try: thing = queue.get(block=False) result.append(thing) except Queue.Empty: # START DEBUG CODE current_size = queue.qsize() total_size =

Pre-allocate space for C++ STL queue

╄→гoц情女王★ 提交于 2019-12-18 10:34:40
问题 I'm writing a radix sort algorithm using queues and I would like to have a STL queue allocate space before I start adding things to the queue so that I can avoid constant dynamic resizing operations. Even though this doesn't exist, I want something with the effect of... queue<int> qs(N); for(int i=0;i<N;++i) qs.push(rand()); in such a way that it will not dynamically allocate any memory during the loop. The actual code in question... void radix_sort() { // Biggest number? int max=-1; for(int

Queues against Tables in messaging systems [closed]

一曲冷凌霜 提交于 2019-12-18 10:17:23
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I've been experiencing the good and the bad sides of messaging systems in real production environments , and I must admit that a well

Is there a queue implementation?

纵然是瞬间 提交于 2019-12-18 10:16:09
问题 Can anyone suggest Go container for simple and fast FIF/queue, Go has 3 different containers: heap , list and vector . Which one is more suitable to implement a queue? 回答1: Either vector or list should work, but vector is probably the way to go. I say this because vector will probably allocate less often than list and garbage collection (in the current Go implementation) is fairly expensive. In a small program it probably won't matter, though. 回答2: In fact, if what you want is a basic and