[Lockfree] spsc example query

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lockfree] spsc example query

Boost - Users mailing list

Hi,

 

I’m just about to start using the spsc queue in a project and whilst reading the example at:

https://www.boost.org/doc/libs/1_74_0/doc/html/lockfree/examples.html#lockfree.examples.waitfree_single_producer_single_consumer_queue

 

looking at the consumer function, there appears to be two while loops retrieving items from the queue inside the outer loop that checks whether the done variable is true.

 

Can somebody please explain why this is, or, is it a bug in the example? I would have thought one inner while loop would be enough.

 

Thanks,

Sean.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Lockfree] spsc example query

Boost - Users mailing list
On 26/08/2020 02:17, Sean Farrow wrote:

> I’m just about to start using the spsc queue in a project and whilst
> reading the example at:
>
> https://www.boost.org/doc/libs/1_74_0/doc/html/lockfree/examples.html#lockfree.examples.waitfree_single_producer_single_consumer_queue
>
> looking at the consumer function, there appears to be two while loops
> retrieving items from the queue inside the outer loop that checks
> whether the done variable is true.
>
> Can somebody please explain why this is, or, is it a bug in the example?
> I would have thought one inner while loop would be enough.

There is only one inner while loop.  The second loop is outside of the
main "while not done" loop.

The second loop is probably intended as a "post-done cleanup" rather
than a "normal processing", although that's disguised by the trivial
nature of the example.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users