An asynchronous, thread-safe queue for RPC requests.
More...
#include <WorkQueue.hpp>
|
| WorkQueue (std::uint32_t numWorkers, uint32_t maxSize=0) |
| Create an we instance of the work queue.
|
|
void | stop (std::function< void()> onQueueEmpty) |
| Put the work queue into a stopping state. This will prevent new jobs from being queued.
|
|
template<typename FnType > |
bool | postCoro (FnType &&func, bool isWhiteListed) |
| Submit a job to the work queue.
|
|
boost::json::object | report () const |
| Generate a report of the work queue state.
|
|
void | join () |
| Wait until all the jobs in the queue are finished.
|
|
size_t | size () const |
| Get the size of the queue.
|
|
An asynchronous, thread-safe queue for RPC requests.
◆ WorkQueue()
rpc::WorkQueue::WorkQueue |
( |
std::uint32_t | numWorkers, |
|
|
uint32_t | maxSize = 0 ) |
Create an we instance of the work queue.
- Parameters
-
numWorkers | The amount of threads to spawn in the pool |
maxSize | The maximum capacity of the queue; 0 means unlimited |
◆ makeWorkQueue()
A factory function that creates the work queue based on a config.
- Parameters
-
config | The Clio config to use |
- Returns
- The work queue
◆ postCoro()
template<typename FnType >
bool rpc::WorkQueue::postCoro |
( |
FnType && | func, |
|
|
bool | isWhiteListed ) |
|
inline |
Submit a job to the work queue.
The job will be rejected if isWhiteListed is set to false and the current size of the queue reached capacity.
- Template Parameters
-
FnType | The function object type |
- Parameters
-
func | The function object to queue as a job |
isWhiteListed | Whether the queue capacity applies to this job |
- Returns
- true if the job was successfully queued; false otherwise
◆ report()
boost::json::object rpc::WorkQueue::report |
( |
| ) |
const |
Generate a report of the work queue state.
- Returns
- The report as a JSON object.
◆ size()
size_t rpc::WorkQueue::size |
( |
| ) |
const |
Get the size of the queue.
- Returns
- The numver of jobs in the queue.
◆ stop()
void rpc::WorkQueue::stop |
( |
std::function< void()> | onQueueEmpty | ) |
|
Put the work queue into a stopping state. This will prevent new jobs from being queued.
- Parameters
-
onQueueEmpty | A callback to run when the last task in the queue is completed |
The documentation for this class was generated from the following files:
- /__w/clio/clio/src/rpc/WorkQueue.hpp
- /__w/clio/clio/src/rpc/WorkQueue.cpp