9 #ifndef CPPCOMMON_THREADS_WAIT_BATCHER_H
10 #define CPPCOMMON_THREADS_WAIT_BATCHER_H
48 explicit operator bool() const noexcept {
return !
closed() && !
empty(); }
90 template <
class InputIterator>
91 bool Enqueue(InputIterator first, InputIterator last);
100 bool Dequeue(std::vector<T>& items);
110 const size_t _capacity;
114 std::vector<T> _batch;
Condition variable synchronization primitive.
Critical section synchronization primitive.
Multiple producers / multiple consumers wait batcher.
void Close()
Close the wait batcher.
bool Dequeue(std::vector< T > &items)
Dequeue all items from the wait batcher.
bool closed() const
Is wait batcher closed?
bool Enqueue(const T &item)
Enqueue an item into the wait batcher.
WaitBatcher(const WaitBatcher &)=delete
size_t capacity() const
Get wait batcher capacity.
WaitBatcher(size_t capacity=0, size_t initial=0)
Default class constructor.
size_t size() const
Get wait batcher size.
bool empty() const
Is wait batcher empty?
WaitBatcher & operator=(WaitBatcher &&)=delete
WaitBatcher & operator=(const WaitBatcher &)=delete
WaitBatcher(WaitBatcher &&)=delete
Condition variable synchronization primitive definition.
C++ Common project definitions.
Multiple producers / multiple consumers wait batcher inline implementation.