libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::detail::ConcurrentContainer< T, Container > Class Template Referenceabstract

#include <concurrent_container.hpp>

Inheritance diagram for fly::detail::ConcurrentContainer< T, Container >:

Public Types

using size_type = typename Container::size_type
 
using value_type = T
 

Public Member Functions

virtual ~ConcurrentContainer ()=default
 
void push (T &&item)
 
void pop (T &item)
 
template<typename R , typename P >
bool pop (T &item, std::chrono::duration< R, P > duration)
 
bool empty () const
 
size_type size () const
 

Protected Member Functions

virtual void push_internal (T &&item)=0
 
virtual void pop_internal (T &item)=0
 

Protected Attributes

std::mutex m_container_mutex
 
Container m_container
 

Detailed Description

template<typename T, typename Container>
class fly::detail::ConcurrentContainer< T, Container >

Wrapper around an STL container to provide thread safe access.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
July 27, 2016

Constructor & Destructor Documentation

◆ ~ConcurrentContainer()

template<typename T , typename Container >
virtual fly::detail::ConcurrentContainer< T, Container >::~ConcurrentContainer ( )
virtualdefault

Destructor.

Member Function Documentation

◆ empty()

template<typename T , typename Container >
bool fly::detail::ConcurrentContainer< T, Container >::empty
Returns
True if the container is empty.

◆ pop() [1/2]

template<typename T , typename Container >
void fly::detail::ConcurrentContainer< T, Container >::pop ( T &  item)

Pop an item from the container. If the container is empty, wait indefinitely for item to be available.

Parameters
itemLocation to store the popped item.

◆ pop() [2/2]

template<typename T , typename Container >
template<typename R , typename P >
bool fly::detail::ConcurrentContainer< T, Container >::pop ( T &  item,
std::chrono::duration< R, P >  duration 
)

Pop an item from the container. If the container is empty, wait (at most) for the specified amount of time for an item to be available.

Parameters
itemLocation to store the popped item.
durationThe amount of time to wait.
Returns
True if an object was popped in the given duration.

◆ pop_internal()

template<typename T , typename Container >
virtual void fly::detail::ConcurrentContainer< T, Container >::pop_internal ( T &  item)
protectedpure virtual

Implementation-specific method to pop an item from the container.

Parameters
itemLocation to store the popped item.

Implemented in fly::ConcurrentQueue< TaskHolder >, fly::ConcurrentStack< T >, fly::ConcurrentQueue< T >, and fly::ConcurrentQueue< EventInfo >.

◆ push()

template<typename T , typename Container >
void fly::detail::ConcurrentContainer< T, Container >::push ( T &&  item)

Move an item onto the container.

Parameters
itemItem to push onto the container.

◆ push_internal()

template<typename T , typename Container >
virtual void fly::detail::ConcurrentContainer< T, Container >::push_internal ( T &&  item)
protectedpure virtual

Implementation-specific method to move an item onto the container.

Parameters
itemItem to push onto the container.

Implemented in fly::ConcurrentQueue< TaskHolder >, fly::ConcurrentStack< T >, fly::ConcurrentQueue< T >, and fly::ConcurrentQueue< EventInfo >.

◆ size()

template<typename T , typename Container >
auto fly::detail::ConcurrentContainer< T, Container >::size
Returns
The number of items in the container.

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