MLIB
Loading...
Searching...
No Matches
mlib::sync_queue< M > Class Template Reference

A template class that implements a "synchronous queue". More...

#include <syncque.h>

Public Member Functions

 sync_queue ()
 Create a synchronous queue.
 
void produce (const M &obj)
 Put new element in queue.
 
void consume (M &obj)
 

Detailed Description

template<class M>
class mlib::sync_queue< M >

A template class that implements a "synchronous queue".

This is, in effect, a mailbox that can store one "message", created by a producer thread, until consumed by a consumer thread.

If the mailbox is full (a message already there), the producer is blocked until the previous message is consumed. If the mailbox is empty, the consumer is blocked until a new message arrives.

This is strictly equivalent with an async_queue with size 1 however it doesn't have the underlining std::queue structure and avoids all the back and forth copying of messages.


The documentation for this class was generated from the following file: