3#include <xrpl/beast/core/LockFreeStack.h>
4#include <xrpl/core/detail/semaphore.h>
Multiple Producer, Multiple Consumer (MPMC) intrusive stack.
std::string const threadName_
Worker(Workers &workers, std::string threadName, int const instance)
std::condition_variable wakeup_
void setNumberOfThreads(int numberOfThreads)
Set the desired number of threads.
void stop()
Pause all threads and wait until they are paused.
std::atomic< int > activeCount_
beast::LockFreeStack< Worker, PausedTag > paused_
int numberOfCurrentlyRunningTasks() const noexcept
Get the number of currently executing calls of Callback::processTask.
std::atomic< int > pauseCount_
void addTask()
Add a task to be performed.
Workers(Callback &callback, perf::PerfLog *perfLog, std::string threadNames="Worker", int numberOfThreads=static_cast< int >(std::thread::hardware_concurrency()))
Create the object.
static void deleteWorkers(beast::LockFreeStack< Worker > &stack)
std::condition_variable cv_
std::atomic< int > runningTaskCount_
beast::LockFreeStack< Worker > everyone_
int getNumberOfThreads() const noexcept
Retrieve the desired number of threads.
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
T hardware_concurrency(T... args)
Dummy class for unit tests.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
BasicSemaphore< std::mutex, std::condition_variable > semaphore
Called to perform tasks as needed.
Callback(Callback const &)=delete
virtual void processTask(int instance)=0
Perform a task.
Callback & operator=(Callback const &)=delete
virtual ~Callback()=default