queue

Does PHP have a peek array operation?

泪湿孤枕 提交于 2019-12-12 12:16:55
问题 I would like to peek at the first element of an array. This operation would be equivalent to this code: function peek($list) { $item = array_shift($list); array_unshift($list, $item); return $item; } This code just seems really heavy to me and peek is often provided by queue and stack libraries. Does php have an already built function or some more efficient way to do this? I searched php.net but was unable to find anything. Additional note for clarity: The array is not necessarily numerically

How to print the BFS path from a source to a target in a maze

房东的猫 提交于 2019-12-12 11:50:29
问题 I'm trying to implement the BFS in order to find the shortest path from a source to a target in a maze. The problem that I'm having is that I'm unable to print the path, it is printed with '*' in the maze, but how can I extract the path from the predecessors of the BFS without printing all the visited nodes? Here's my code for you to compile: #include <stdio.h> #include <stdlib.h> #include <string.h> struct coord{ //This is a struct I'll use to store coordinates int row; int col; }; //-------

sort a queue in C#

霸气de小男生 提交于 2019-12-12 11:23:07
问题 Even though this question sounds as a duplicate, I searched a lot but couldn't find a proper solution. I have following classes public enum ChangeType { Add, Modify, Delete } public enum ChangedObjectType { Project, Customer, Border, Photo } public struct ChangeInfo { public ChangeType typeofChange { get; private set; } public ChangedObjectType objectType { get; private set; } public string objectID { get; private set; } public ChangeInfo(ChangeType changeType, ChangedObjectType changeObj,

Retrying messages where my code fails with AWS SQS

北城以北 提交于 2019-12-12 10:45:09
问题 I've been trying to find out more information on having a retry and error queue where my code fails rather than having in-memory retries in my application. Here's my scenario: I'm sending a message saying something along the lines of: "Process the output for this task - It want's you to update this xml file with the contents of this stream". I have code that writes output to an xml file but it can occasionally fail and need retried as It's possible that another part of my application/person

Passing a Queue to ThreadedHTTPServer

半腔热情 提交于 2019-12-12 10:09:17
问题 I would like to pass a Queue object to a base ThreadedHTTPServer implementation. My existing code works just fine, but I would like a safe way to send calls to and from my HTTP requests. Normally this would probably be handled by a web framework, but this is a HW limited environment. My main confusion comes on how to pass the Queue (or any) object to allow access to other modules in my environment. The base code template I have currently running: import base64,threading,urlparse,urllib2,os,re

Queue Multithreaded Methods for Execution

天涯浪子 提交于 2019-12-12 09:52:14
问题 All, I have a generic method called TaskSpin , in this method I launch a Task with an ascociated continutation public TaskSpin(Func asyncMethod, object[] methodParameters) { ... asyncTask = Task.Factory.StartNew<bool>(() => asyncMethod(uiScheduler, methodParameters)); asyncTask.ContinueWith(task => { // Finish the processing update UI etc. } ... } The problem is now that I want to run multiple methods using TaskSpin , but I need to restrict the methods to run one-at-a-time. So foreach row in

Is the JMS QueueSender thread safe?

五迷三道 提交于 2019-12-12 08:19:51
问题 I want to use a QueueSender in a multi-threaded environment. Is QueueSender.send() thread safe? 回答1: No, a MessageProducer / QueueSender is not thread safe. Or more specifically: The Session is not thread safe. The JavaDoc for Session explicitly mentions this in its first sentence: A Session object is a single-threaded context for producing and consuming messages. And since a MessageProducer / QueueSender is bound to a Session you must not use it from more than one thread at the same time. In

Delphi: Threaded list of thread jobs - queueing

和自甴很熟 提交于 2019-12-12 08:15:28
问题 I have some operations which are based on TThreads. Now I need to create the thread containing the list of jobs to be done, then firing each one as soon as the previous finishes... How should I write it? I can't allow the threads to be ran simultaneously as there might be over 10 000 operations to be done. It is quite hard to find documented examples of TEvent and other syncing objects... Hope I'll find some help here ... Thanks in advance, michal 回答1: Don't base your operations on threads.

How to capture job queue details after completion in Laravel 5.1?

扶醉桌前 提交于 2019-12-12 08:13:20
问题 In Laravel 5.1, I would like to be notified when a job is completed, with details about the job (specifically, the user_id , and customer_id ). I'm using the Queue::after method method in the AppServiceProvider as Laravel suggests. If a dump the $data parameter like so: Queue::after(function ($connection, $job, $data) { var_dump($data); exit; }); I get the following: array(2) { ["job"]=> string(39) "Illuminate\Queue\CallQueuedHandler@call" ["data"]=> array(1) { ["command"]=> string(263) "O:23

GCD serial queue does not seem to execute serially

坚强是说给别人听的谎言 提交于 2019-12-12 07:37:47
问题 I have a method that at times can be invoked throughout my code. Below is a very basic example, as the code processes images and files off of the iphone photo gallery and marks them already processed when done with the method. @property (nonatomic, assign) dispatch_queue_t serialQueue; .... -(void)processImages { dispatch_async(self.serialQueue, ^{ //block to process images NSLog(@"In processImages"); .... NSLog(@"Done with processImages"); }); } I would think that each time this method is