Clio develop
The XRP Ledger API server.
|
CoroutineGroup is a helper class to manage a group of coroutines. It allows to spawn multiple coroutines and wait for all of them to finish. More...
#include <CoroutineGroup.hpp>
Public Member Functions | |
CoroutineGroup (boost::asio::yield_context yield, std::optional< size_t > maxChildren=std::nullopt) | |
Construct a new Coroutine Group object. | |
~CoroutineGroup () | |
Destroy the Coroutine Group object. | |
bool | spawn (boost::asio::yield_context yield, std::function< void(boost::asio::yield_context)> fn) |
Spawn a new coroutine in the group. | |
std::optional< std::function< void()> > | registerForeign () |
Register a foreign coroutine this group should wait for. | |
void | asyncWait (boost::asio::yield_context yield) |
Wait for all the coroutines in the group to finish. | |
size_t | size () const |
Get the number of coroutines in the group. | |
bool | isFull () const |
Check if the group is full. | |
CoroutineGroup is a helper class to manage a group of coroutines. It allows to spawn multiple coroutines and wait for all of them to finish.
util::CoroutineGroup::CoroutineGroup | ( | boost::asio::yield_context | yield, |
std::optional< size_t > | maxChildren = std::nullopt ) |
Construct a new Coroutine Group object.
yield | The yield context to use for the internal timer |
maxChildren | The maximum number of coroutines that can be spawned at the same time. If not provided, there is no limit |
util::CoroutineGroup::~CoroutineGroup | ( | ) |
Destroy the Coroutine Group object.
void util::CoroutineGroup::asyncWait | ( | boost::asio::yield_context | yield | ) |
Wait for all the coroutines in the group to finish.
yield | The yield context to use for the internal timer |
bool util::CoroutineGroup::isFull | ( | ) | const |
Check if the group is full.
std::optional< std::function< void()> > util::CoroutineGroup::registerForeign | ( | ) |
Register a foreign coroutine this group should wait for.
size_t util::CoroutineGroup::size | ( | ) | const |
Get the number of coroutines in the group.
bool util::CoroutineGroup::spawn | ( | boost::asio::yield_context | yield, |
std::function< void(boost::asio::yield_context)> | fn ) |
Spawn a new coroutine in the group.
yield | The yield context to use for the coroutine (it should be the same as the one used in the constructor) |
fn | The function to execute |