12 #ifndef THRILL_COMMON_CONCURRENT_QUEUE_HEADER 13 #define THRILL_COMMON_CONCURRENT_QUEUE_HEADER 29 template <
typename T,
typename Allocator>
53 std::unique_lock<std::mutex> lock(mutex_);
54 queue_.push_back(source);
60 std::unique_lock<std::mutex> lock(mutex_);
61 queue_.push_back(std::move(elem));
66 template <
typename... Arguments>
68 std::unique_lock<std::mutex> lock(mutex_);
69 queue_.emplace_back(std::forward<Arguments>(args) ...);
74 std::unique_lock<std::mutex> lock(mutex_);
75 return queue_.empty();
81 std::unique_lock<std::mutex> lock(mutex_);
85 destination = std::move(queue_.front());
92 std::unique_lock<std::mutex> lock(mutex_);
100 #endif // !THRILL_COMMON_CONCURRENT_QUEUE_HEADER bool empty() const
Returns: true if queue has no items; false otherwise.
bool try_pop(T &destination)
ConcurrentQueue(const Allocator &alloc=Allocator())
Constructor.
This is a queue, similar to std::queue and tbb::concurrent_queue, except that it uses mutexes for syn...
void emplace(Arguments &&... args)
std::deque< T, Allocator > queue_
the actual data queue
std::ptrdiff_t difference_type
std::mutex mutex_
the mutex to lock before accessing the queue
void clear()
Clears the queue.
void push(const T &source)
Pushes a copy of source onto back of the queue.