|
template<typename... Args> |
int | configure (option flag, Args &&...args) |
| Sets additional loop options.
|
|
template<typename R , typename... Args> |
std::shared_ptr< R > | resource (Args &&...args) |
| Creates resources of any type.
|
|
template<typename R , typename... Args> |
std::shared_ptr< R > | uninitialized_resource (Args &&...args) |
| Creates uninitialized resources of any type.
|
|
int | close () |
| Releases all internal loop resources.
|
|
int | run (run_mode mode=run_mode::DEFAULT) noexcept |
| Runs the event loop.
|
|
bool | alive () const noexcept |
| Checks if there are active resources.
|
|
void | stop () noexcept |
| Stops the event loop.
|
|
int | descriptor () const noexcept |
| Get backend file descriptor.
|
|
std::pair< bool, time > | timeout () const noexcept |
| Gets the poll timeout.
|
|
time | idle_time () const noexcept |
| Returns the amount of time the event loop has been idle. The call is thread safe.
|
|
metrics_type | metrics () const noexcept |
| Tracks various internal operations of the event loop.
|
|
time | now () const noexcept |
| Returns the current timestamp in milliseconds.
|
|
void | update () const noexcept |
| Updates the event loop’s concept of now.
|
|
template<typename Func > |
void | walk (Func callback) |
| Walks the list of handles.
|
|
int | fork () noexcept |
| Reinitialize any kernel state necessary in the child process after a fork(2) system call.
|
|
template<typename R = void> |
std::shared_ptr< R > | data () const |
| Gets user-defined data. uvw won't use this field in any case.
|
|
void | data (std::shared_ptr< void > ud) |
| Sets arbitrary data. uvw won't use this field in any case.
|
|
const uv_loop_t * | raw () const noexcept |
| Gets the underlying raw data structure.
|
|
uv_loop_t * | raw () noexcept |
| Gets the underlying raw data structure.
|
|
void | on (listener_t< U > f) |
| Registers a long-lived listener with the event emitter.
|
|
void | reset () noexcept |
| Disconnects the listener for the given event type.
|
|
void | reset () noexcept |
| Disconnects all listeners.
|
|
bool | has () const noexcept |
| Checks if there is a listener registered for the specific event.
|
|
The loop class.
The event loop is the central part of uvw
's functionalities, as well as libuv
's ones.
It takes care of polling for I/O and scheduling callbacks to be run based on different sources of events.
Definition at line 60 of file loop.h.
template<typename... Args>
int uvw::loop::configure |
( |
option |
flag, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Sets additional loop options.
You should normally call this before the first call to uv_run() unless mentioned otherwise.
Supported options:
loop::option::BLOCK_SIGNAL
: Block a signal when polling for new events. A second argument is required and it is the signal number.
loop::option::IDLE_TIME
: Accumulate the amount of idle time the event loop spends in the event provider. This option is necessary to use idle_time()
.
See the official documentation for further details.
- Returns
- Underlying return value.
Definition at line 139 of file loop.h.
Reinitialize any kernel state necessary in the child process after a fork(2) system call.
Previously started watchers will continue to be started in the child process.
It is necessary to explicitly call this function on every event loop created in the parent process that you plan to continue to use in the child, including the default loop (even if you don’t continue to use it in the parent). This function must be called before calling any API function using the loop in the child. Failure to do so will result in undefined behaviour, possibly including duplicate events delivered to both parent and child or aborting the child process.
When possible, it is preferred to create a new loop in the child process instead of reusing a loop created in the parent. New loops created in the child process after the fork should not use this function.
Note that this function is not implemented on Windows.
Note also that this function is experimental in libuv
. It may contain bugs, and is subject to change or removal. API and ABI stability is not guaranteed.
See the official documentation for further details.
- Returns
- Underlying return value.
const uv_loop_t * uvw::loop::raw |
( |
| ) |
const |
|
noexcept |
Gets the underlying raw data structure.
This function should not be used, unless you know exactly what you are doing and what are the risks.
Going raw is dangerous, mainly because the lifetime management of a loop, a handle or a request is in charge to the library itself and users should not work around it.
- Warning
- Use this function at your own risk, but do not expect any support in case of bugs.
- Returns
- The underlying raw data structure.
uv_loop_t * uvw::loop::raw |
( |
| ) |
|
|
noexcept |
Gets the underlying raw data structure.
This function should not be used, unless you know exactly what you are doing and what are the risks.
Going raw is dangerous, mainly because the lifetime management of a loop, a handle or a request is in charge to the library itself and users should not work around it.
- Warning
- Use this function at your own risk, but do not expect any support in case of bugs.
- Returns
- The underlying raw data structure.
template<typename R , typename... Args>
std::shared_ptr< R > uvw::loop::resource |
( |
Args &&... |
args | ) |
|
|
inline |
Creates resources of any type.
This should be used as a default method to create resources.
The arguments are the ones required for the specific resource.
Use it as loop->resource<uvw::timer_handle>()
.
- Returns
- A pointer to the newly created resource.
Definition at line 154 of file loop.h.