Subject: Re: [boost] [lockfree] wait-free multi-queue?
From: Gavin Lambert (boost_at_[hidden])
Date: 2019-01-18 03:52:47


On 18/01/2019 15:38, Shawn Yarbrough wrote:
> Is it practical to have a wait-free, multi-producer/multi-consumer queue?
>
> I ask because Boost's Lockfree multi-queue is only advertised as being
> "lock-free". (Boost does offer a wait-free single-queue.)

I know of a wait-free multi-producer single-consumer queue, if that
helps. (Although it has a caveat that the consumer will sometimes see
the queue as empty if a producer is interrupted at exactly the wrong
moment.)

You can also synthesize a crude MPSC queue yourself by giving each
producer its own SPSC pipeline and make the consumer read all of them.
Or the reverse for SPMC (publish-model, where every consumer gets a
copy). Though the downside of doing this is that it takes more planning
of the number of each that exist, so it's less flexible.