olp-cpp-sdk  1.21.0
Public Member Functions | List of all members
olp::thread::SyncQueue< T, Container > Class Template Referencefinal

A thread-safe container adapter. More...

#include <SyncQueue.h>

Public Member Functions

 SyncQueue (const SyncQueue &)=delete
 Non-copyable, non-movable.
 
SyncQueueoperator= (const SyncQueue &)=delete
 Non-copyable, non-movable.
 
 SyncQueue (SyncQueue &&)=delete
 Non-copyable, non-movable.
 
SyncQueueoperator= (SyncQueue &&)=delete
 Non-copyable, non-movable.
 
bool Empty () const
 Checks whether this SyncQueue instance is empty. More...
 
void Close ()
 Closes this SyncQueue instance, deletes all the queued elements, and blocks you from pulling any elements from the queue.
 
bool Pull (T &element)
 Pulls one element from the SyncQueue instance. More...
 
void Push (T &&element)
 Forwards the passed element into the SyncQueue instance. More...
 
void Push (const T &element)
 Copies the passed element into the SyncQueue instance. More...
 

Detailed Description

template<typename T, typename Container>
class olp::thread::SyncQueue< T, Container >

A thread-safe container adapter.

Template Parameters
TThe queue item that should be stored inside the buffer.
ContainerThe type of the underlying container that should mimic the API of std::queue that provides the following functions:
  • empty()
  • push(T&&)
  • push(const T&)
  • front()
  • pop()

Member Function Documentation

◆ Empty()

template<typename T , typename Container >
bool olp::thread::SyncQueue< T, Container >::Empty
inline

Checks whether this SyncQueue instance is empty.

Returns
True if this SyncQueue instance is empty; false otherwise.

◆ Pull()

template<typename T , typename Container >
bool olp::thread::SyncQueue< T, Container >::Pull ( T &  element)
inline

Pulls one element from the SyncQueue instance.

Parameters
elementThe element pulled from the queue.
Returns
True if the pull was successful; false if the SyncQueue instance was closed. Once closed, the SyncQueue instance does not open again.

◆ Push() [1/2]

template<typename T , typename Container >
void olp::thread::SyncQueue< T, Container >::Push ( const T &  element)
inline

Copies the passed element into the SyncQueue instance.

Parameters
elementThe const lvalue reference to the element.

◆ Push() [2/2]

template<typename T , typename Container >
void olp::thread::SyncQueue< T, Container >::Push ( T &&  element)
inline

Forwards the passed element into the SyncQueue instance.

Parameters
elementThe rvalue reference to the element.

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