Questions tagged [concurrent-queue]

Concurrent Queue is thread-safe first in - first out (FIFO) collection.

Concurrent Queue is thread-safe first in - first out (FIFO) collection/container.

Implementations

93 questions
3
votes
0 answers

ConcurrentQueue size limit and time frame

I am looking for a way to : read messages from a ConcurrentQueue limited to some size. read not more then X message at a time frame. I want to stop the reading from Q once one of the 2 hit, until other code is done and do the same thing again. I…
developer learn999
  • 365
  • 1
  • 4
  • 17
3
votes
2 answers

How to release reference from the ConcurentQueue for the item dequeued from the concurrent queue with TryDequeue

I am using ConcurrentQueue (C#, ASP.NET Core) for holding tasks for the upload of the big files. I have a very big memory consumption even after items are dequeued from the concurrent queue. Items are not cleared from the memory. I understand…
Vedran
  • 143
  • 10
3
votes
2 answers

Concurrent Queue Issue - iOS/Swift

In my program I need two tasks to run simultaneously in the background. To do that i have used concurrent queues as below, let concurrentQueue = DispatchQueue(label: "concurrentQueue", qos: .utility, attributes: .concurrent) concurrentQueue.async…
Hanushka Suren
  • 723
  • 3
  • 10
  • 32
3
votes
3 answers

ConcurrentQueue with multithreading

I am new to multi threading concepts. I need to add certain number of strings to a queue and process them with multiple threads. Using ConcurrentQueue which is thread safe. This is what I have tried. But all the items added into concurrent queue are…
Naveen kumar
  • 239
  • 2
  • 6
  • 19
3
votes
1 answer

Cannot create new ConcurrentQueue on Windows 10?

I'm trying to use the HashLib library in a Windows 10 app, but it throws an unhandled exception (System.MethodAccessException): Attempt by method 'HashLib.Hash.TransformStream(System.IO.Stream, Int64)' to access method…
markus
  • 177
  • 1
  • 13
3
votes
0 answers

Custom Boost Asio IO object

I am new to boost asio. I've read this comparison: How does libuv compare to Boost/ASIO? (Dead link) It turned out that there is an opportunity to use asio's event loop for other reasons but socket programming. I am planning to use this async event…
3
votes
1 answer

How do I iterate concurrent queue repeatedly?

I am using Winforms and targeting .Net 4.5 I want to iterate concurrent queue for as long as it has items. In my application, the user can add and remove items to the concurrent queue at any point. Sample code: ConcurrentQueue cq = new…
TH Todorov
  • 1,129
  • 11
  • 26
2
votes
3 answers

Difference between Queue's and Concurrent Queue's TryDequeue method

Both collections, Queue and ConcurrentQueue have a method TryDequeue. What is the difference between using TryDequeue with Queue and ConcurrentQueue respectively? Is Queue's TryDequeue method thread-safe in multi-threading environment?
user1080381
  • 1,597
  • 1
  • 16
  • 22
2
votes
4 answers

When to choose serialQueue over concurrent queue in ios

I was asked to implement a thread safe dictionary in swift, I used the common approach: class MutableDictionary { var dictionary: [String : Any] = [:] var queue = DispatchQueue(label: "queue", attributes: .concurrent) func…
2
votes
2 answers

Atomically taking everything from a ConcurrentQueue

I have multiple threads generating items and sticking them in a common ConcurrentQueue: private ConcurrentQueue queuedItems = new ConcurrentQueue(); private void BunchOfThreads () { // ... …
Jason C
  • 38,729
  • 14
  • 126
  • 182
2
votes
0 answers

How to output data from Threadpool to ConcurrentQueue (C#)?

I have written an application for my company that essentially sends records from a text or CSV file in arrays of 100 records to a web service, to which it then returns the response, also in arrays of 100 records and writes them to another file.…
2
votes
1 answer

Why weird behavior of concurrent queue?

I am trying to understanding the concurrent queue of iOS GCD. The I made some code to test it, but found something weird. code as below: _syncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); for (int index = 0; index < 3; ++index)…
onTheWay
  • 128
  • 1
  • 8
2
votes
1 answer

What is the Rust equivalent to Intel's tbb::concurrent_queue?

I am looking for an equivalent of the concurrent_queue from Intel's tbb module in Rust. I have found some crates: multiqueue two-lock-queue crossbeam-deque and even futures-pool thread-pool I feel like they are all doing similar things, however…
2
votes
1 answer

Split a ConcurrentLinkedQueue into half using Spliterator

I have a ConcurrentLinkedQueue and I want to split it into two halves and let two separate threads handle each. I have tried using Spliterator but I do not understand how to get the partitioned queues. ConcurrentLinkedQueue q = // contains a…
a_fan
  • 383
  • 2
  • 22
2
votes
1 answer

Efficient file writing using BlockingCollection

I have a producer consumer scenario. Producer produces data for BlockingCollection and some other thread consumes it. When consumer takes an item it must write it to a text file. There is no limit how much data can be produced by producer thread so…
Alias
  • 341
  • 2
  • 3
  • 14