queue

Queue using Arrays

人走茶凉 提交于 2020-01-06 14:49:48
问题 Below is my implementation of a simple queue using arrays. #include<stdio.h> #include<stdlib.h> #define QSIZE 5 //Limit size of queue to just 5 enteries /*Beginning of prototype for queue functions: Insert, retrieve and display*/ void qdisp(); //Display to queue array contents void qinsert(); //Insert a element into rear of queue int qdelete(); //Remove an element from front of queue /*End of prototyping*/ // Variables int fe=0,re=0,q[QSIZE],item; //fe(front entry), re(rear entry), q[](queue

How to queue requests when underlying framework does not support queueing?

£可爱£侵袭症+ 提交于 2020-01-06 10:09:30
问题 I feel my question is really n00b; apologies if I don't word it clearly :/ In my project I'm using a 3rd party framework that fetches some data for me using asynchronous NSURLRequests (RESTful API). When the data is received and ready, delegate function didReceiveResponse is called. On error case didFailWithError is called. The problem is: framework cannot queue requests, so if I call request methods sequentially I only receive the response for the last request issued. Now the issue is that I

Laravel Lumen Queue Failure with queue:work but not queue:listen

别来无恙 提交于 2020-01-06 07:13:43
问题 I have an issue where I have a command that inserts jobs into a DB queue. I have a service "supervisor" basically running artisan queue:work continuesily (I should also mention I have a once per min cron job running artisan schedule:run). If I just run this command and let the supervisor pick up when the queued job should run I get this exception: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method App\Services\MiddlewareApi::get_lowest_active_customer_number_by

Laravel Lumen Queue Failure with queue:work but not queue:listen

六月ゝ 毕业季﹏ 提交于 2020-01-06 07:13:10
问题 I have an issue where I have a command that inserts jobs into a DB queue. I have a service "supervisor" basically running artisan queue:work continuesily (I should also mention I have a once per min cron job running artisan schedule:run). If I just run this command and let the supervisor pick up when the queued job should run I get this exception: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method App\Services\MiddlewareApi::get_lowest_active_customer_number_by

No performance gain after using multiprocessing for a queue-oriented function

丶灬走出姿态 提交于 2020-01-06 04:23:07
问题 The real code I want to optimize is too complicated to be included here, so here is a simplified example: def enumerate_paths(n, k): """ John want to go up a flight of stairs that has N steps. He can take up to K steps each time. This function enumerate all different ways he can go up this flight of stairs. """ paths = [] to_analyze = [(0,)] while to_analyze: path = to_analyze.pop() last_step = path[-1] if last_step >= n: # John has reach the top paths.append(path) continue for i in range(1,

Priority queue with two priority values

五迷三道 提交于 2020-01-05 12:10:56
问题 As it is good known, elements which are inserted to the priority queue have a value which determines its priority. For example if I have five elements A,B,C,D,E with priorities (let's call this priority values priorityI ): A = 10, B = 5, C = 1, D = 3, E = 2 . But how can I write a priority queue where I can define two priority values, I mean: if two elements has the same value of priorityI , then value priorityII decides which element should be taken first, like for example: element A has

Queue print jobs in a separate single Thread for JavaFX

主宰稳场 提交于 2020-01-05 04:31:12
问题 currently I am experimenting with Concurrency in Java/JavaFX. Printing must run in a different thread otherwise it will make the JavaFX main thread freeze for a couple seconds. Right now my printing is done with this simplified example. public void print(PrintContent pt) { setPrintContent(pt); Thread thread = new Thread(this); thread.start(); } @Override public void run() { // send content to printer } With this code I am sending many print jobs parallel to my printer. Therefore I get the

How can i use two stacks(LIFO) so that it can work like a queue(FIFO)?

醉酒当歌 提交于 2020-01-05 03:04:08
问题 I have two stacks(which follows LIFO). I would like to know if i can write a C program to use these two stacks work like a queue(FIFO). 回答1: One stack is used to insert new elements into the queue. The other stack is used to remove elements. When the output stack is empty, the input stack is reversed and becomes the new output stack. In pseudo-C: typedef struct { stack in, stack out } queue. void insert(queue *q, void *data) { push(q->in, data); } void* remove(queue *q) { if (empty(q->out)) {

NServiceBus Single Process, but Multiple Input queues

醉酒当歌 提交于 2020-01-04 15:28:34
问题 We are trying to get many applications to communicate together and drive actions in each other via NSB. I would like to put each app into its own queue for two reasons: make it easier for support to troubleshoot problems and (possibly) have another place where I could scale the app. The bus will be hosted inside a windows service, possible just single instance that all apps will share. Each app can publish a message that will be picked up by windows service and processed using assemblies from

Extending a non-generic class to a generic class

核能气质少年 提交于 2020-01-04 14:29:39
问题 The Java class CircularFifoBuffer in the package org.apache.commons.collections.buffer is non-generic, and can store objects of any class. I would like to create a generified version of this, that can only hold objects of class T. My first thought was to extend CircularFifoBuffer and simply write a new 'add' method: public class CircularFifoQueue<T> extends CircularFifoBuffer { public boolean add(T data) { return super.add(data); } } However, this leaves the old 'add' method in place,