Subject: Re: [boost] [concurrent] Fast, lock-based queue implementation
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-18 03:10:07
David Stone wrote:
> On Sat, Jun 17, 2017 at 10:26 PM, Peter Dimov via Boost <
> boost_at_[hidden]> wrote:
> > - If C++14 is required, why not use the standard thread/chrono
> > facilities?
> Excellent question that I should document. std::thread does not support
> interruption, boost::thread does. I find this feature compelling enough to
> justify using the boost version over the standard. The next best
> alternative, as far as I know, is to do the equivalent of adding a "stop
> processing messages" message to the queue.
Natively supporting this mode of operation is not a bad idea in its own
right. This is sometimes preferable to the interruption approach because it
guarantees that the consumers will drain the queue before shutting down (and
that guarantee comes for free, no effort is required on part of the user, as
long as the producers are shut down beforehand.)
You will also need tests.