queue

After every Enqueue() all the values in the Queue become the same

拟墨画扇 提交于 2020-04-30 07:33:06
问题 I'm receiving some data over a socket and trying to add it to a Queue so it can be dequeued by another thread that is much more slow, something like a buffer. The problem is that everytime I enqueue a new value, all the values in the queue become that. byte[] aux = new byte[1464]; aux = (byte[])ar.AsyncState; //add the package to the package fifo list lock (lockPktBuffer) { packetBuffer.Enqueue(aux); } First I thought that I was passing a pointer, so all the entries are just pointing to the

How would I go about using concurrent.futures and queues for a real-time scenario?

匆匆过客 提交于 2020-04-27 23:28:56
问题 It is fairly easy to do parallel work with Python 3's concurrent.futures module as shown below. with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: future_to = {executor.submit(do_work, input, 60): input for input in dictionary} for future in concurrent.futures.as_completed(future_to): data = future.result() It is also very handy to insert and retrieve items into a Queue. q = queue.Queue() for task in tasks: q.put(task) while not q.empty(): q.get() I have a script running

How would I go about using concurrent.futures and queues for a real-time scenario?

我怕爱的太早我们不能终老 提交于 2020-04-27 23:27:23
问题 It is fairly easy to do parallel work with Python 3's concurrent.futures module as shown below. with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: future_to = {executor.submit(do_work, input, 60): input for input in dictionary} for future in concurrent.futures.as_completed(future_to): data = future.result() It is also very handy to insert and retrieve items into a Queue. q = queue.Queue() for task in tasks: q.put(task) while not q.empty(): q.get() I have a script running

how to process time taking request in laravel?

时光总嘲笑我的痴心妄想 提交于 2020-04-18 06:11:51
问题 I am trying to read data from excel file and and then store it in database. but there is problem . sometimes file has a lot of data nearly 20000 records. when I try to process that request with that much data it process for 2 to 3 minutes and enter around 13000 record in database and after that request got failed. here is what i am doing . this process gets completed in five functions every functions has it own job. Now, I think I should do it by queue but i have no idea how it will work

how to process time taking request in laravel?

自闭症网瘾萝莉.ら 提交于 2020-04-18 06:11:37
问题 I am trying to read data from excel file and and then store it in database. but there is problem . sometimes file has a lot of data nearly 20000 records. when I try to process that request with that much data it process for 2 to 3 minutes and enter around 13000 record in database and after that request got failed. here is what i am doing . this process gets completed in five functions every functions has it own job. Now, I think I should do it by queue but i have no idea how it will work

How to process data from a file in parallel in several threads and write them into another file while keeping the original data order (C#)

北城以北 提交于 2020-03-23 09:02:20
问题 I would like to ask you rather a general question (even though I'm rather interested in how to achieve it in C#). I have a huge file which I want to read by chunks, process the chunks somehow in parallel in several threads to make the processing faster and then write the processed data to another file in the same order as the original data chunks were read (i.e. making sure that the first data chunk read from the input file will be processed and saved first in the output file, the second

Is there a C# class like Queue that implements IAsyncEnumerable?

心不动则不痛 提交于 2020-03-22 15:45:35
问题 Both Queue and ConcurrentQueue implement IEnumerable but not IAsyncEnumerable . Is there a standard class or class available on NuGet which implements IAsyncEnumerable such that, if the queue is empty, the result of MoveNextAsync does not complete until something next is added to the queue? 回答1: If you are using the .NET Core platform there are at least two built-in options: The System.Threading.Tasks.Dataflow.BufferBlock<T> class, part of the TPL Dataflow library. It doesn't implement the

Multiple queues from one multiprocessing Manager

北慕城南 提交于 2020-03-02 21:44:01
问题 I'm writing a script that will use python's multiprocessing and threading module. For your understanding, I spawn as much processes as cores are available and inside each process I start e.g. 25 threads. Each thread consumes from an input_queue and produces to an output_queue . For the queue object I use multiprocessing.Queue . After my first tests I got a deadlock because the the thread responsible to feed and flush the Queue was hanging. After a while I found that I can use Queue().cancel

Multiple queues from one multiprocessing Manager

纵然是瞬间 提交于 2020-03-02 21:43:36
问题 I'm writing a script that will use python's multiprocessing and threading module. For your understanding, I spawn as much processes as cores are available and inside each process I start e.g. 25 threads. Each thread consumes from an input_queue and produces to an output_queue . For the queue object I use multiprocessing.Queue . After my first tests I got a deadlock because the the thread responsible to feed and flush the Queue was hanging. After a while I found that I can use Queue().cancel

Pass param packed args into a std::queue to call with a different function later

随声附和 提交于 2020-02-23 06:44:30
问题 I asked a similar question earlier without realizing that that wasn't quite specific enough. So I have this function that has to take in all the arguments of a print function, with the ... and all, and then put it into a queue that will call the actual print function later. Something like: std::queue<SOMETHING> queue; template <typename... Params> void printLater(int a, int b, char* fmt, Params ...args) { queue.push(args); } template <typename... Params> void print(int a, int b, char* fmt,