23#include <xrpl/basics/base_uint.h>
25#include <condition_variable>
47 mutable std::mutex m_;
48 std::condition_variable cv_;
72 std::unique_lock lck(m_);
73 cv_.wait(lck, [
this]() {
return queue_.size() <= maxSize_; });
88 std::unique_lock lck(m_);
89 cv_.wait(lck, [
this]() {
return queue_.size() <= maxSize_; });
90 queue_.push(std::move(elt));
104 std::unique_lock lck(m_);
105 cv_.wait(lck, [
this]() {
return !queue_.empty(); });
107 T ret = std::move(queue_.front());
122 std::scoped_lock
const lck(m_);
126 T ret = std::move(queue_.front());
141 return queue_.size();
151std::vector<ripple::uint256>
Generic thread-safe queue with a max capacity.
Definition ETLHelpers.hpp:44
std::optional< T > tryPop()
Attempt to pop an element.
Definition ETLHelpers.hpp:120
std::size_t size() const
Get the size of the queue.
Definition ETLHelpers.hpp:139
void push(T &&elt)
Push element onto the queue.
Definition ETLHelpers.hpp:86
T pop()
Pop element from the queue.
Definition ETLHelpers.hpp:102
void push(T const &elt)
Push element onto the queue.
Definition ETLHelpers.hpp:70
ThreadSafeQueue(uint32_t maxSize)
Create an instance of the queue.
Definition ETLHelpers.hpp:58
This namespace contains everything to do with the ETL and ETL sources.
Definition CacheLoader.hpp:36
std::vector< ripple::uint256 > getMarkers(size_t numMarkers)
Parititions the uint256 keyspace into numMarkers partitions, each of equal size.
Definition ETLHelpers.cpp:31