|
xrpld
|
Manages a set of objects performing asynchronous I/O. More...
#include <io_list.h>

Classes | |
| class | Work |
Public Member Functions | |
| IOList ()=default | |
| ~IOList () | |
| Destroy the list. | |
| bool | closed () const |
| Return true if the list is closed. | |
| template<class T, class... Args> | |
| std::shared_ptr< T > | emplace (Args &&... args) |
| Create associated work if not closed. | |
| template<class Finisher> | |
| void | close (Finisher &&f) |
| Cancel active I/O. | |
| void | close () |
| template<class = void> | |
| void | join () |
| Block until the io_list stops. | |
Private Member Functions | |
| template<class = void> | |
| void | destroy () |
Private Attributes | |
| std::mutex | m_ |
| std::size_t | n_ = 0 |
| bool | closed_ = false |
| std::condition_variable | cv_ |
| boost::container::flat_map< Work *, std::weak_ptr< Work > > | map_ |
| std::function< void(void)> | f_ |
|
default |
| xrpl::IOList::~IOList | ( | ) |
|
nodiscard |
| std::shared_ptr< T > xrpl::IOList::emplace | ( | Args &&... | args | ) |
Create associated work if not closed.
Requirements: std::is_base_of_v<Work, T> == true
Thread Safety: May be called concurrently.
Effects: Atomically creates, inserts, and returns new work T, or returns nullptr if the io_list is closed,
If the call succeeds and returns a new object, it is guaranteed that a subsequent call to close will invoke Work::close on the object.
| void xrpl::IOList::close | ( | Finisher && | f | ) |
Cancel active I/O.
Thread Safety: May not be called concurrently.
Effects: Associated work is closed.
Finisher if provided, will be called when all associated work is destroyed. The finisher may be called from a foreign thread, or within the call to this function.
Only the first call to close will set the finisher.
No effect after the first call.
| void xrpl::IOList::join | ( | ) |
Block until the io_list stops.
Effects: The caller is blocked until the io_list is closed and all associated work is destroyed.
Thread safety: May be called concurrently.
Preconditions: No call to io_context::run on any io_context used by work objects associated with this io_list exists in the caller's call stack.
|
private |
|
private |
|
private |
|
private |
|
private |