queue

string producer/consumer in C++: std::deque<char> or std::stringstream?

余生颓废 提交于 2019-12-11 01:06:19
问题 In our application we have a class that produces characters, and another that consumes them. The current implementation dynamically allocates characters as they are produced (using new ) and delete them (with delete ) as they are consumed. This is all terribly slow, and I am looking at ways to replace that implementation to improve its performance. The semantic I need is that of the standard class queue : push at the front, pop at the back. The default implementation uses a deque IIRC. deque

Enqueue laravel event subscriber

浪尽此生 提交于 2019-12-11 01:03:13
问题 I'm handling multiple events through an Event Subscriber instead making separated Events/Listeners. I would like to enqueue several of these events but I didn't find a way to accomplish that. I've followed the official documentation (https://laravel.com/docs/5.2/events#event-subscribers), but there is no clue of how to choose what events I want to enqueue(neither all the subscriber). Any suggestions? (No individual Event/Listener, please) Thanks in advance! 回答1: If anyone is interested in, I

Queue of array of characters

烈酒焚心 提交于 2019-12-11 00:40:31
问题 include <queue> using namespace std; char msg[1000]; Now, I want to have a queue that can store 5 of this kind of msg. So, it is a queue of size 5 that contains 5 arrays of characters, each array can contain up to 1000 chars. How can I initiate the queue? I tried this but it did not work. char msg[1000]; queue<msg> p; 回答1: Edit: std::vector may be better choice, just reread you question and saw the size of the character array. If you are using it to store binary data, a std::queue< std:

Recommended usage of TPL for very long living threads

风流意气都作罢 提交于 2019-12-11 00:07:29
问题 I've read some of the MSDN documentation for the Task Parallel Library (http://msdn.microsoft.com/en-us/library/dd537609(v=vs.110).aspx) specifically about the best practice usage of the TPL. I have an application which starts up a thread. The purpose of the thread is to monitor a queue and "process" items which have been added. The processing of the items on the queue needs to be done sequentially and so I am not looking to processes multiple items at once form the queue. The thread lives as

Python mulitprocessing queue isn't keeping all the workers busy

余生长醉 提交于 2019-12-10 23:56:09
问题 I have a pipeline that runs on a single core that I am trying to run hundreds of times in parallel over the 32 cores of an aws instance. The hope is that once a run is complete, the next one will start. I have written a queueing script based on one I found online and it seems to work but the efficiency trails off as if some workers are not accepting new processes but some are. Here is the main code from my script (not sure why the indents are not showing up when I cut and paste here - they

An efficient way to implement a custom generic list/queue/stack combination

守給你的承諾、 提交于 2019-12-10 23:26:25
问题 I have found more than one occasions where a generic collection needs to be treated as a list at one point in time and as a stack or queue at another time. For an an application I'm currently developing, it does not make sense to use three separate objects. The simplest solution I could think of was to implement Queue/Dequeue/Push/Pop/Peek functions on the standard List. Also (not included in the code below), an interface constraint is applied on T allowing the class to maintains a position

how to deepcopy a queue in python

流过昼夜 提交于 2019-12-10 22:12:50
问题 Hi How to deepcopy a Queue in python? Thanks 回答1: The queue module in Python is used for synchronizing shared data between threads. It is not intended as a data structure and it doesn't support copying (not even shallow copy). (It is possible to construct many deepcopy's of a Queue by .get and .put , but the original Queue will be destroyed.) If you want to have a queue (or stack) as a data structure, use a collections.deque. If you want a priority queue, use the heapq module. The deque

AVAssetWriter queue guidance Swift 3

耗尽温柔 提交于 2019-12-10 21:50:48
问题 can anyone give me some guidance on using Queues in AVFoundation please? Later on in my app I want to do some processing on individual frames so I need to use AVCaptureVideoDataOutput. To get started I thought I'd capture images and then write them (unprocessed) using AVAssetWriter. I am successfully streaming frames from camera to image preview by setting up an AVCapture session as follows: func initializeCameraAndMicrophone() { // set up the captureSession captureSession = AVCaptureSession(

VBA System.Collections.Queue

烈酒焚心 提交于 2019-12-10 21:48:20
问题 I just discovered here the 'built-in' Stacks and Queues available from VBA. The way it's written, I can't see the properties and methods of the Queue object. Dim queue As Object Set queue = CreateObject("System.Collections.Queue") 'Create the Queue queue.Enqueue "Hello" 'VBE does not show the available properties and methods So my question is: is there a reference I can use that will allow me to have early binding and benefit from the VBE autocomplete ? Something like: Dim queue As System

ConcurrentQueue holds object's reference or value? “out of memory” exception

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 21:15:31
问题 Is objects enqueued to a ConcurrentQueue are copied to the queue or just their references? I don't understand any scenario. Explanation: I defined a ConcurrentQueue like this: // BufferElement is a class I created private ConcurrentQueue<BufferElement> _bufferQueue; I have a function which is called a lot of times and it's purpsoe is to enqueue an element to the queue: private void EnqueueElementToBuffer(string data, int moreData) { // the bufferElement constructor is setting data and