|
uvw
1.3.0
|
#include <loop.hpp>


Public Member Functions | |
| template<typename... Args> | |
| void | configure (Configure flag, Args &&... args) |
| Sets additional loop options. More... | |
| template<typename R , typename... Args> | |
| std::enable_if_t< std::is_base_of< BaseHandle, R >::value, std::shared_ptr< R > > | resource (Args &&... args) |
| Creates resources of handles' types. More... | |
| template<typename R , typename... Args> | |
| std::enable_if_t< not std::is_base_of< BaseHandle, R >::value, std::shared_ptr< R > > | resource (Args &&... args) |
| Creates resources of types other than handles' ones. More... | |
| void | close () |
| Releases all internal loop resources. More... | |
| template<Mode mode = Mode::DEFAULT> | |
| bool | run () noexcept |
| Runs the event loop. More... | |
| bool | alive () const noexcept |
| Checks if there are active resources. More... | |
| void | stop () noexcept |
| Stops the event loop. More... | |
| int | descriptor () const noexcept |
| Get backend file descriptor. More... | |
| std::pair< bool, Time > | timeout () const noexcept |
| Gets the poll timeout. More... | |
| Time | now () const noexcept |
| Returns the current timestamp in milliseconds. More... | |
| void | update () const noexcept |
| Updates the event loop’s concept of now. More... | |
| void | walk (std::function< void(BaseHandle &)> callback) |
| Walks the list of handles. More... | |
| void | fork () noexcept |
| Reinitialize any kernel state necessary in the child process after a fork(2) system call. More... | |
Public Member Functions inherited from uvw::Emitter< Loop > | |
| Connection< E > | on (Listener< E > f) |
| Registers a long-lived listener with the event emitter. More... | |
| Connection< E > | once (Listener< E > f) |
| Registers a short-lived listener with the event emitter. More... | |
| void | erase (Connection< E > conn) noexcept |
| Disconnects a listener from the event emitter. More... | |
| void | clear () noexcept |
| Disconnects all the listeners for the given event type. | |
| void | clear () noexcept |
| Disconnects all the listeners. | |
| bool | empty () const noexcept |
| Checks if there are listeners registered for the specific event. More... | |
| bool | empty () const noexcept |
| Checks if there are listeners registered with the event emitter. More... | |
Static Public Member Functions | |
| static std::shared_ptr< Loop > | create () |
| Initializes a new Loop instance. More... | |
| static std::shared_ptr< Loop > | getDefault () |
| Gets the initialized default loop. More... | |
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.
|
inlinenoexcept |
|
inline |
Releases all internal loop resources.
Call this function only when the loop has finished executing and all open handles and requests have been closed, or the loop will emit an error.
An ErrorEvent will be emitted in case of errors.
|
inline |
Sets additional loop options.
You should normally call this before the first call to uv_run() unless mentioned otherwise.
Supported options:
Loop::Configure::BLOCK_SIGNAL: Block a signal when polling for new events. A second argument is required and it is the signal number.An ErrorEvent will be emitted in case of errors.
See the official documentation for further details.
|
inlinestatic |
|
inlinenoexcept |
|
inlinenoexcept |
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.
An ErrorEvent will be emitted in case of errors.
See the official documentation for further details.
|
inlinestatic |
Gets the initialized default loop.
It may return an empty pointer in case of failure.
This function is just a convenient way for having a global loop throughout an application, the default loop is in no way different than the ones initialized with create().
As such, the default loop can be closed with close() so the resources associated with it are freed (even if it is not strictly necessary).
|
inlinenoexcept |
Returns the current timestamp in milliseconds.
The timestamp is cached at the start of the event loop tick.
The timestamp increases monotonically from some arbitrary point in time.
Don’t make assumptions about the starting point, you will only get disappointed.
std::chrono::duration<uint64_t, std::milli>).
|
inline |
Creates resources of handles' types.
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::TimerHandle>().
|
inline |
Creates resources of types other than handles' ones.
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::WorkReq>().
|
inlinenoexcept |
Runs the event loop.
Available modes are:
Loop::Mode::DEFAULT: Runs the event loop until there are no more active and referenced handles or requests.Loop::Mode::ONCE: Poll for i/o once. Note that this function blocks if there are no pending callbacks.Loop::Mode::NOWAIT: Poll for i/o once but don’t block if there are no pending callbacks.See the official documentation for further details.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Updates the event loop’s concept of now.
The current time is cached at the start of the event loop tick in order to reduce the number of time-related system calls.
You won’t normally need to call this function unless you have callbacks that block the event loop for longer periods of time, where longer is somewhat subjective but probably on the order of a millisecond or more.
|
inline |
1.8.13