queue

Priority Queue C

空扰寡人 提交于 2019-12-24 23:48:11
问题 I'm trying to create a priority queue using an array of queues, each index of the array being a priority. I tried the following solution, The queue data type contains an array llist, Queue *q_create(int size) { struct queue *p; struct q_head *h; int i; if ((p = (struct queue *)malloc(sizeof(struct queue))) != NULL) { p->size = size; for (i = 0; i < PRIODIFF; i++) { h = &(p->llist[i]); h->head = NULL; h->tail = NULL; } } return p; } I'm confused by the line: h = &(p->llist[i]); I was thinking

Discrepancies in time when using DispatchQueue in Swift

房东的猫 提交于 2019-12-24 21:01:09
问题 I've got a code which must be executed every half a second and I'm using the Xcode playground. I used this top answer and got a code like this: for (index, item) in array.enumerated() { DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(index), execute: { print("\(index) - \(df.string(from: Date()))" //play sound every second }) } This code is executed every second (I know that I have to divide it by 2 to get half a second but wanted to see the results). I used the DateFormatter to

AFNetworking: downloading files in queue

余生长醉 提交于 2019-12-24 20:16:13
问题 I just started using AFNetworking and so far it worked fine for just getting data from the web. But now I have a list of files that need to be downloaded to the device for(NSDictionary *issueDic in data) { Issue *issue = [[Issue alloc] init]; ... [self getOrDownloadCover:issue]; ... } getOrDownloadCover:issue checks if a file already exists locally, if it does, it just saves that path, if it doesn't, it downloads the file from a given url - (void)getOrDownloadCover:(Issue *)issue { NSLog(@

Kentico - “Send email queue” scheduled task stuck

二次信任 提交于 2019-12-24 20:02:46
问题 Our client can't received email and I have found the issue with the schedule task "Send email queue": The task couldn't not stop before I disabled it. When I enable again, it works fine, but I want to know exactly the problem to not sure it NOT stuck again More detail: - Kentico: v10.0.50 - Event log: i dôn't see any log about the task 回答1: Best thing to resolve that issue is to upgrade to a newer version. There are a list of things about a mile long which could cause it to hang. We've found

Is the volatile mark necessary for a queue with one thread adding and another reading?

放肆的年华 提交于 2019-12-24 19:48:49
问题 in response to some comments in this thread, I am wondering if making a queue that will have one thread adding to it and another thread reading from it requires the 'volatile' mark? I suppose most cases would be alright, but in the case of reading and writing in a queue of size 1 could cause issues without it? Goal: a thread safe queue where I can post messages to be sent over a TCP socket connection. The out stream will be managed by another class who will check if the queue is empty at the

How to find if a HeapQueue contains a value in Java?

时光总嘲笑我的痴心妄想 提交于 2019-12-24 19:41:05
问题 I am having trouble writing a method with finding if a MaxHeapPriorityQueue contains a value. The instructions read: The contains(E) method should return true if the given value is found in the queue. It should use its private helper method to search the queue recursively. Here is what I have so far public class MaxHeapPriorityQueue<E extends Comparable<E>> { private E[] elementData; private int size; @SuppressWarnings("unchecked") public MaxHeapPriorityQueue() { elementData = (E[]) new

Correct approach to initialize an asynchronous JMS Listener and let it run infinitely

与世无争的帅哥 提交于 2019-12-24 18:49:19
问题 I use the following application to connect to my oracle database, register a queue listener and wait for enqueued messages: package sample; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueSession; import javax.jms.Session; import oracle.jms.AQjmsFactory; import oracle.jms.AQjmsSession; public class MyThread extends Thread { private static final String QUEUE

Spring TaskExecutor Implementation Queue Priorization

僤鯓⒐⒋嵵緔 提交于 2019-12-24 18:32:06
问题 The application I am working on receives notifications from external systems, which I want to process. Till now I have the following implementation: public class AsynchronousServiceImpl implements AsynchronousService { private TaskExecutor taskExecutor; @Override public void executeAsynchronously(Runnable task) { taskExecutor.execute(task); } @Required public void setTaskExecutor(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; } } spring configuration (I only need 1 thread

Laravel & Laravel Forge returns “MaxAttemptsExceededException:” even when tries are set at 1

怎甘沉沦 提交于 2019-12-24 18:32:05
问题 My error log is getting filled with this useless text, I have set my job to only try once and the time out to 0 because the jobs can be really long and it depends on the user. So the job has tries set at 1 timeout at 0, on laravel forge I have set my worker to have max tries at 1 and timeout 0, and still it gives me this error in the logs: Illuminate\Queue\MaxAttemptsExceededException: A queued job has been attempted too many times. The job may have previously timed out. in /home/forge

Alternative for Zend Job Queue

扶醉桌前 提交于 2019-12-24 17:44:10
问题 Is it alternative solution for Zend Job Queue what could be used without Zend Server ? My application need to accept quick request and provide quick response (receipt) and limit this part to database entry. After this additional process should be executed in background to analyze this request (generate PDF file, send emails with PDF, send text message, etc) I do not want to initial request to wait for all those actions to finish - just provide receipt and let server do it a few seconds later.