|
rippled
|
A group of threads that process tasks. More...

Classes | |
| struct | Callback |
| Called to perform tasks as needed. More... | |
| struct | PausedTag |
| class | Worker |
Public Member Functions | |
| Workers (Callback &callback, perf::PerfLog *perfLog, std::string const &threadNames="Worker", int numberOfThreads=static_cast< int >(std::thread::hardware_concurrency())) | |
| Create the object. More... | |
| ~Workers () | |
| int | getNumberOfThreads () const noexcept |
| Retrieve the desired number of threads. More... | |
| void | setNumberOfThreads (int numberOfThreads) |
| Set the desired number of threads. More... | |
| void | pauseAllThreadsAndWait () |
| Pause all threads and wait until they are paused. More... | |
| void | addTask () |
| Add a task to be performed. More... | |
| int | numberOfCurrentlyRunningTasks () const noexcept |
| Get the number of currently executing calls of Callback::processTask. More... | |
Static Private Member Functions | |
| static void | deleteWorkers (beast::LockFreeStack< Worker > &stack) |
Private Attributes | |
| Callback & | m_callback |
| perf::PerfLog * | perfLog_ |
| std::string | m_threadNames |
| std::condition_variable | m_cv |
| std::mutex | m_mut |
| bool | m_allPaused |
| semaphore | m_semaphore |
| int | m_numberOfThreads |
| std::atomic< int > | m_activeCount |
| std::atomic< int > | m_pauseCount |
| std::atomic< int > | m_runningTaskCount |
| beast::LockFreeStack< Worker > | m_everyone |
| beast::LockFreeStack< Worker, PausedTag > | m_paused |
|
explicit |
Create the object.
A number of initial threads may be optionally specified. The default is to create one thread per CPU.
| threadNames | The name given to each created worker thread. |
Definition at line 27 of file Workers.cpp.
| ripple::Workers::~Workers | ( | ) |
Definition at line 45 of file Workers.cpp.
|
noexcept |
Retrieve the desired number of threads.
This just returns the number of active threads that were requested. If there was a recent call to setNumberOfThreads, the actual number of active threads may be temporarily different from what was last requested.
Definition at line 53 of file Workers.cpp.
| void ripple::Workers::setNumberOfThreads | ( | int | numberOfThreads | ) |
Set the desired number of threads.
Definition at line 63 of file Workers.cpp.
| void ripple::Workers::pauseAllThreadsAndWait | ( | ) |
Pause all threads and wait until they are paused.
If a thread is processing a task it will pause as soon as the task completes. There may still be tasks signaled even after all threads have paused.
Definition at line 114 of file Workers.cpp.
| void ripple::Workers::addTask | ( | ) |
Add a task to be performed.
Every call to addTask will eventually result in a call to Callback::processTask unless the Workers object is destroyed or the number of threads is never set above zero.
Definition at line 126 of file Workers.cpp.
|
noexcept |
Get the number of currently executing calls of Callback::processTask.
While this function is thread-safe, the value may not stay accurate for very long. It's mainly for diagnostic purposes.
Definition at line 132 of file Workers.cpp.
|
staticprivate |
Definition at line 138 of file Workers.cpp.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
1.8.17