Signal handle. More...
#include "handle-misc.hpp"
Public Types | |
using | uv_t = ::uv_signal_t |
using | on_signal_t = std::function< void(signal _handle, bool _oneshot) > |
The function type of the signal callback. More... | |
Public Types inherited from uv::handle | |
using | uv_t = ::uv_handle_t |
using | on_destroy_t = std::function< void(void *_data) > |
The function type of the callback called when the handle has been closed and about to be destroyed. More... | |
Public Member Functions | |
signal (const signal &)=default | |
signal & | operator= (const signal &)=default |
signal (signal &&) noexcept=default | |
signal & | operator= (signal &&) noexcept=default |
signal (uv::loop &_loop, int _signum) | |
Create a signal handle watching for _signum signal. | |
int | signum () const noexcept |
Get the signal number being watched for by this handle. | |
on_signal_t & | on_signal () const noexcept |
Set the signal callback. | |
int | start () const |
Start the handle for watching for the signal. More... | |
template<class _Cb_ , typename... _Args_, typename = std::enable_if_t< std::is_convertible< decltype(std::bind(std::declval< _Cb_ >(), std::placeholders::_1, std::placeholders::_2, static_cast< _Args_&& >(std::declval< _Args_ >())...)), on_signal_t >::value >> | |
int | start (_Cb_ &&_cb, _Args_ &&... _args) const |
Start the handle with the given signal callback. More... | |
template<class _Cb_ , typename... _Args_, typename = std::enable_if_t< std::is_convertible< decltype(std::bind(std::declval< _Cb_ >(), std::placeholders::_1, std::placeholders::_2, static_cast< _Args_&& >(std::declval< _Args_ >())...)), on_signal_t >::value >> | |
int | start (int _signum, _Cb_ &&_cb, _Args_ &&... _args) const |
Start the handle with the given signal callback, watching for the given signal number. More... | |
int | stop () const noexcept |
Stop the handle, the callback will no longer be called. | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
Public Member Functions inherited from uv::handle | |
handle (const handle &_that) | |
handle & | operator= (const handle &_that) |
handle (handle &&_that) noexcept | |
handle & | operator= (handle &&_that) noexcept |
void | swap (handle &_that) noexcept |
std::uintptr_t | id () const noexcept |
The unique ID of the instance managed by this handle variable or 0 if the handle is void. | |
long | nrefs () const noexcept |
The current number of existing references to the same object as this handle variable refers to. | |
int | uv_status () const noexcept |
The status value returned by the last executed libuv API function on this handle. | |
on_destroy_t & | on_destroy () const noexcept |
::uv_handle_type | type () const noexcept |
The tag indicating the libuv type of the handle. | |
const char * | type_name () const noexcept |
A string containing the name of the handle type. | |
uv::loop | loop () const noexcept |
The libuv loop where the handle is running on. More... | |
void *& | data () const noexcept |
The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field. | |
int | is_active () const noexcept |
Check if the handle is active. More... | |
int | is_closing () const noexcept |
Check if the handle is closing or closed. More... | |
::uv_os_fd_t | fileno () const noexcept |
Get the platform dependent handle/file descriptor. More... | |
operator const uv_t * () const noexcept | |
operator uv_t * () noexcept | |
operator bool () const noexcept | |
Equivalent to (id() and uv_status() >= 0) . | |
void | attached (bool _state) const noexcept |
bool | attached () const noexcept |
Signal handle.
uv_signal_t
— Signal handle. Definition at line 1009 of file handle-misc.hpp.
using uv::signal::on_signal_t = std::function< void(signal _handle, bool _oneshot) > |
The function type of the signal callback.
The _oneshot
parameter indicates that the signal handling was started in mode of start_oneshot()
function.
uv_signal_cb
. Definition at line 1021 of file handle-misc.hpp.
|
inline |
Start the handle for watching for the signal.
Repeated call to this function results in the automatic call to stop()
first (possible signal events are not missed if the signal number has not changed).
stop()
is called. uv_signal_t
— Signal handle. Definition at line 1140 of file handle-misc.hpp.
|
inline |
Start the handle with the given signal callback.
This is equivalent for
signal::start()
Definition at line 1155 of file handle-misc.hpp.
|
inline |
Start the handle with the given signal callback, watching for the given signal number.
This function overload allows to change the signal number being watched for by the handle. This is equivalent for
signal::start()
Definition at line 1178 of file handle-misc.hpp.