1#ifndef XRPL_CORE_WORKERS_H_INCLUDED
2#define XRPL_CORE_WORKERS_H_INCLUDED
4#include <xrpld/core/detail/semaphore.h>
6#include <xrpl/beast/core/LockFreeStack.h>
Multiple Producer, Multiple Consumer (MPMC) intrusive stack.
std::string const threadName_
std::condition_variable wakeup_
Workers is effectively a thread pool.
std::condition_variable m_cv
int getNumberOfThreads() const noexcept
Retrieve the desired number of threads.
static void deleteWorkers(beast::LockFreeStack< Worker > &stack)
beast::LockFreeStack< Worker, PausedTag > m_paused
int numberOfCurrentlyRunningTasks() const noexcept
Get the number of currently executing calls of Callback::processTask.
void addTask()
Add a task to be performed.
std::string m_threadNames
beast::LockFreeStack< Worker > m_everyone
std::atomic< int > m_activeCount
std::atomic< int > m_pauseCount
void stop()
Pause all threads and wait until they are paused.
std::atomic< int > m_runningTaskCount
void setNumberOfThreads(int numberOfThreads)
Set 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)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Called to perform tasks as needed.
virtual ~Callback()=default
Callback & operator=(Callback const &)=delete
virtual void processTask(int instance)=0
Perform a task.
Callback(Callback const &)=delete