14 _batch.reserve(initial);
37 return _batch.capacity();
57 if ((_capacity == 0) || (_batch.size() < _capacity))
59 _batch.push_back(item);
64 _cv2.Wait(_cs, [
this]() {
return (_closed || (_capacity == 0) || (_batch.size() < _capacity)); });
81 if ((_capacity == 0) || (_batch.size() < _capacity))
83 _batch.emplace_back(item);
88 _cv2.Wait(_cs, [
this]() {
return (_closed || (_capacity == 0) || (_batch.size() < _capacity)); });
96 template <
class InputIterator>
106 if ((_capacity == 0) || (_batch.size() < _capacity))
108 _batch.insert(_batch.end(), first, last);
113 _cv2.Wait(_cs, [
this]() {
return (_closed || (_capacity == 0) || (_batch.size() < _capacity)); });
128 if (_closed && _batch.empty())
141 _cv1.Wait(_cs, [
this]() {
return (_closed || !_batch.empty()); });
143 }
while (!_closed || !_batch.empty());
Locker synchronization primitive.
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.
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.
C++ Common project definitions.
void swap(FileCache &cache1, FileCache &cache2) noexcept