Thrill  0.1
ConcurrentQueue< T, Allocator > Class Template Reference

Detailed Description

template<typename T, typename Allocator>
class thrill::common::ConcurrentQueue< T, Allocator >

This is a queue, similar to std::queue and tbb::concurrent_queue, except that it uses mutexes for synchronization.

StyleGuide is violated, because signatures are expected to match those of std::queue.

Definition at line 30 of file concurrent_queue.hpp.

+ Inheritance diagram for ConcurrentQueue< T, Allocator >:

#include <concurrent_queue.hpp>

Public Types

using const_reference = const T &
 
using difference_type = std::ptrdiff_t
 
using reference = T &
 
using size_type = std::size_t
 
using value_type = T
 

Public Member Functions

 ConcurrentQueue (const Allocator &alloc=Allocator())
 Constructor. More...
 
void clear ()
 Clears the queue. More...
 
template<typename... Arguments>
void emplace (Arguments &&... args)
 
bool empty () const
 Returns: true if queue has no items; false otherwise. More...
 
void push (const T &source)
 Pushes a copy of source onto back of the queue. More...
 
void push (T &&elem)
 
bool try_pop (T &destination)
 

Private Attributes

std::mutex mutex_
 the mutex to lock before accessing the queue More...
 
std::deque< T, Allocator > queue_
 the actual data queue More...
 

Member Typedef Documentation

◆ const_reference

using const_reference = const T&

Definition at line 35 of file concurrent_queue.hpp.

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 37 of file concurrent_queue.hpp.

◆ reference

using reference = T&

Definition at line 34 of file concurrent_queue.hpp.

◆ size_type

using size_type = std::size_t

Definition at line 36 of file concurrent_queue.hpp.

◆ value_type

using value_type = T

Definition at line 33 of file concurrent_queue.hpp.

Constructor & Destructor Documentation

◆ ConcurrentQueue()

ConcurrentQueue ( const Allocator &  alloc = Allocator())
inlineexplicit

Constructor.

Definition at line 48 of file concurrent_queue.hpp.

Member Function Documentation

◆ clear()

void clear ( )
inline

Clears the queue.

Definition at line 91 of file concurrent_queue.hpp.

◆ emplace()

void emplace ( Arguments &&...  args)
inline

Pushes a new element into the queue. The element is constructed with given arguments.

Definition at line 67 of file concurrent_queue.hpp.

◆ empty()

bool empty ( ) const
inline

Returns: true if queue has no items; false otherwise.

Definition at line 73 of file concurrent_queue.hpp.

◆ push() [1/2]

void push ( const T source)
inline

Pushes a copy of source onto back of the queue.

Definition at line 52 of file concurrent_queue.hpp.

◆ push() [2/2]

void push ( T &&  elem)
inline

Pushes given element into the queue by utilizing element's move constructor

Definition at line 59 of file concurrent_queue.hpp.

◆ try_pop()

bool try_pop ( T destination)
inline

If value is available, pops it from the queue, assigns it to destination, and destroys the original value. Otherwise does nothing.

Definition at line 80 of file concurrent_queue.hpp.

Member Data Documentation

◆ mutex_

std::mutex mutex_
mutableprivate

the mutex to lock before accessing the queue

Definition at line 44 of file concurrent_queue.hpp.

◆ queue_

std::deque<T, Allocator> queue_
private

the actual data queue

Definition at line 41 of file concurrent_queue.hpp.


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