20 #ifndef RIPPLE_CORE_WORKERS_H_INCLUDED
21 #define RIPPLE_CORE_WORKERS_H_INCLUDED
23 #include <ripple/beast/core/LockFreeStack.h>
24 #include <ripple/core/impl/semaphore.h>
116 int numberOfThreads =
std::condition_variable m_cv
virtual void processTask(int instance)=0
Perform a task.
void stop()
Pause all threads and wait until they are paused.
static void deleteWorkers(beast::LockFreeStack< Worker > &stack)
std::atomic< int > m_pauseCount
int getNumberOfThreads() const noexcept
Retrieve the desired number of threads.
beast::LockFreeStack< Worker, PausedTag > m_paused
beast::LockFreeStack< Worker > m_everyone
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...
Worker(Workers &workers, std::string const &threadName, int const instance)
std::condition_variable wakeup_
Called to perform tasks as needed.
std::string m_threadNames
std::atomic< int > m_activeCount
std::atomic< int > m_runningTaskCount
T hardware_concurrency(T... args)
const std::string threadName_
Workers(Callback &callback, perf::PerfLog *perfLog, std::string const &threadNames="Worker", int numberOfThreads=static_cast< int >(std::thread::hardware_concurrency()))
Create the object.
Workers is effectively a thread pool.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Callback & operator=(Callback const &)=delete
void addTask()
Add a task to be performed.
virtual ~Callback()=default
int numberOfCurrentlyRunningTasks() const noexcept
Get the number of currently executing calls of Callback::processTask.
Multiple Producer, Multiple Consumer (MPMC) intrusive stack.