xenium
Public Member Functions | List of all members
xenium::michael_scott_queue< T, Policies > Class Template Reference

An unbounded generic lock-free multi-producer/multi-consumer FIFO queue. More...

#include <michael_scott_queue.hpp>

Public Member Functions

void push (T value)
 Pushes the given value to the queue. More...
 
bool try_pop (T &result)
 Tries to pop an object from the queue. If the operation is successful, the object will be moved to result. More...
 

Detailed Description

template<class T, class... Policies>
class xenium::michael_scott_queue< T, Policies >

An unbounded generic lock-free multi-producer/multi-consumer FIFO queue.

This is an implementation of the lock-free MPMC queue proposed by Michael and Scott [MS96]. It is fully generic and can handle any type T that is copyable or movable.

Supported policies:

Template Parameters
Ttype of the stored elements.
Policieslist of policies to customize the behaviour

Member Function Documentation

◆ push()

template<class T , class... Policies>
void xenium::michael_scott_queue< T, Policies >::push ( value)

Pushes the given value to the queue.

This operation always allocates a new node. Progress guarantees: lock-free (always performs a memory allocation)

Parameters
value

◆ try_pop()

template<class T , class... Policies>
bool xenium::michael_scott_queue< T, Policies >::try_pop ( T &  result)

Tries to pop an object from the queue. If the operation is successful, the object will be moved to result.

Progress guarantees: lock-free

Parameters
result
Returns
true if the operation was successful, otherwise false