Questions tagged [producer-consumer]

The Producer-Consumer Problem (also known as the bounded-buffer problem) is a classical example of a multi-process synchronization problem. The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue.

14 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
16 votes
0 answers
3k views

Realtime concurrent Haskell MIDI buffer

Problem Background MIDI is a serial representation of control signals to a sound generator. Typically, a noteOn message initiates the attack phase of a sound at a given pitch. The note will ...
user1441998's user avatar
5 votes
0 answers
2k views

Disruptor pattern in a lock-free producer-consumer queue

I'm implementing a quick-and-dirty lock-free MPMC queue in C++, based on the v3 Disruptor algorithm. The implementation is pretty simple: Data to be shared between threads is stored in a ring buffer. ...
linguamachina's user avatar
4 votes
0 answers
376 views

Java multithreading many readers one writer implementations

I have a shared data object with writer threads and reader threads. Number of threads can read from the shared data at the same time (in the code getmethod), and ...
user avatar
4 votes
0 answers
411 views

Producer-consumer with a twist (consumer is a reader) in C++

Executive summary The twist is that the consumers do not consume, they just read. The producer makes items continuously in one of two alternating slots. Readers read from the other slot. When ...
Adrian Rosoga's user avatar
3 votes
0 answers
1k views

C++ Producer / Consumer multi threads pattern with maximum container size

I've just written a Producer / Consumer pattern templatized that should work in multi threads environment (IE producer(s) and consumer(s) in separate threads). The original use case is one producer ...
Romain Laneuville's user avatar
3 votes
0 answers
310 views

Optimal Implementation Choice for Producer-Consumer in Java

I am looking for an optimal producer-consumer implementation in Java with the following aspects: Producer reads from server1 socket, and writes to a shared buffer, as well as another server 2 socket: ...
tsar2512's user avatar
  • 131
2 votes
0 answers
179 views

producer-consumer Pipeline problem implementation in asyncio

I wrote this code to make a non-blocking manager along with pipeline operations using asyncio, my main concern is to catch received items producer, and when the received operation is complete. I want ...
etyzz's user avatar
  • 21
2 votes
0 answers
228 views

Managing exceptions in aiohttp using consumer-producer pattern

I implemented a simple producer-consumer where producer produces links to fetch and several workers consume those URLs and return write data into response queue. Unfortunately, sometimes API can start ...
ig-melnyk's user avatar
  • 151
2 votes
0 answers
1k views

Many-readers-one-writer with semaphores and multithreading

I've been looking for a solution to the may readers one writer in Java. I was intrigued by this question posted here and I read the Wikipedia entry about it. So far, I've reached a fine solution, or ...
Oscar Besga Panel's user avatar
2 votes
0 answers
579 views

Producer Consumer Using TPL Dataflow

I have written the following class which is supposed to act as a consumer of messages that are passed in from producers and forward them onto amazon SQS, I have made a compromise by starting the ...
xerxes's user avatar
  • 327
2 votes
0 answers
644 views

Producer / consumer pattern with limits on .NET

For a project that I'm developing, I need to implement the producer/consumer pattern, but the quantity of consumers cannot be higher than some number (say 40). I created a concept project on GitHub ...
Vladimir Venegas's user avatar
2 votes
0 answers
104 views

Porting Java semaphore to MacOSX

I wanted to write some more JNI code and decided to (re)implement a semaphore for MacOSX. In order to assert somehow correctness of my implementation I hereby supply a (multi)consumer/(multi)producer ...
coderodde's user avatar
  • 28.1k
1 vote
0 answers
970 views

First readers-writers problem using a single condition

For the first readers-writers problem, in which readers can access a given resource simultaneously, is the following Python3 solution correct? Problem parameters: One set of data is shared among a ...
Pedro Lopes's user avatar
1 vote
0 answers
1k views

Load balancing consumer and producer with multiprocessing

Tasks are distributed to producer in multiple worker process. Results from workers are sent through Queue to a ...
hamster on wheels's user avatar