Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OurConcurrentBoundedQueue< T > Class Template Reference

Detailed Description

template<typename T>
class thrill::common::OurConcurrentBoundedQueue< T >

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

This implementation is only here to be used if the Intel TBB is not available.

Not all methods of tbb::concurrent_bounded_queue<> are available here, please add them if you need them. However, NEVER add any other methods that you might need.

StyleGuide is violated, because signatures MUST match those in the TBB version.

Definition at line 55 of file concurrent_bounded_queue.hpp.

+ Inheritance diagram for OurConcurrentBoundedQueue< T >:

#include <concurrent_bounded_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

 OurConcurrentBoundedQueue ()=default
 default constructor More...
 
 OurConcurrentBoundedQueue (OurConcurrentBoundedQueue &&other)
 move-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 pop (T &destination)
 
template<typename Rep , typename Period >
bool pop_for (T &destination, const std::chrono::duration< Rep, Period > &timeout)
 
void push (const T &source)
 Pushes a copy of source onto back of the queue. More...
 
void push (T &&elem)
 
size_t size ()
 
bool try_pop (T &destination)
 

Private Attributes

std::condition_variable cv_
 condition variable signaled when an item arrives More...
 
std::mutex mutex_
 the mutex to lock before accessing the queue More...
 
std::queue< Tqueue_
 the actual data queue More...
 

Member Typedef Documentation

using const_reference = const T &

Definition at line 60 of file concurrent_bounded_queue.hpp.

using difference_type = std::ptrdiff_t

Definition at line 62 of file concurrent_bounded_queue.hpp.

using reference = T &

Definition at line 59 of file concurrent_bounded_queue.hpp.

using size_type = std::size_t

Definition at line 61 of file concurrent_bounded_queue.hpp.

using value_type = T

Definition at line 58 of file concurrent_bounded_queue.hpp.

Constructor & Destructor Documentation

default constructor

move-constructor

Definition at line 79 of file concurrent_bounded_queue.hpp.

Member Function Documentation

void clear ( )
inline

Clears the queue.

Definition at line 115 of file concurrent_bounded_queue.hpp.

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

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

Definition at line 102 of file concurrent_bounded_queue.hpp.

bool empty ( ) const
inline

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

Definition at line 109 of file concurrent_bounded_queue.hpp.

void pop ( T destination)
inline

If value is available, pops it from the queue, move it to destination. If no item is in the queue, wait until there is one.

Definition at line 134 of file concurrent_bounded_queue.hpp.

bool pop_for ( T destination,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

If value is available, pops it from the queue, move it to destination. If no item is in the queue, wait until there is one, or timeout and return false. NOTE: not available in TBB!

Definition at line 145 of file concurrent_bounded_queue.hpp.

void push ( const T source)
inline

Pushes a copy of source onto back of the queue.

Definition at line 85 of file concurrent_bounded_queue.hpp.

void push ( T &&  elem)
inline

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

Definition at line 93 of file concurrent_bounded_queue.hpp.

size_t size ( )
inline

return number of items available in the queue (tbb says "can return negative size", due to pending pop()s, but we ignore that here).

Definition at line 158 of file concurrent_bounded_queue.hpp.

bool try_pop ( T destination)
inline

If value is available, pops it from the queue, move it to destination, destroying the original position. Otherwise does nothing.

Definition at line 122 of file concurrent_bounded_queue.hpp.

Member Data Documentation


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