|
xentara-utils v2.1
The Xentara Utility Library
|
A class that registers handlers that catch termination signals and events. More...
#include <xentara/utils/application/TerminateHandler.hpp>
Inheritance diagram for xentara::utils::application::TerminateHandler:Classes | |
| struct | ConstructorOptions |
| Options for creating terminate handlers. More... | |
Public Types | |
| enum class | State { Run , Suspend , Terminate } |
| States. More... | |
Public Member Functions | |
| TerminateHandler (ConstructorOptions options={}) | |
| Constructor that registers the handlers. | |
| ~TerminateHandler () | |
| Destructor that unregisters the handlers. | |
Static Public Member Functions | |
Wait functions | |
| static auto | wait () -> void |
| Waits until the Terminate state has been reached. | |
| static auto | wait (State oldState) -> State |
| Waits until the state differs from a given state. | |
| static auto | waitFor (const std::chrono::system_clock::duration &timeout) -> bool |
| Waits until the Terminate state has been reached using a relative timeout. | |
| static auto | waitFor (State oldState, const std::chrono::system_clock::duration &timeout) -> State |
| Waits until the state differs from a given state using a relative timeout. | |
| static auto | waitUntil (const std::chrono::system_clock::time_point &timeoutTime) -> bool |
| Waits until the terminate state has been reached using an absolute timeout. | |
| static auto | waitUntil (State oldState, const std::chrono::system_clock::time_point &timeoutTime) -> State |
| Waits until the state differs from a given state using an absolute timeout. | |
Wait functions that do not throw exceptions | |
| static auto | wait (const std::nothrow_t &tag) noexcept -> void |
| Waits until the Terminate state has been reached. | |
| static auto | wait (State oldState, const std::nothrow_t &tag) noexcept -> State |
| Waits until the state differs from a given state. | |
| static auto | waitFor (const std::chrono::system_clock::duration &timeout, const std::nothrow_t &tag) noexcept -> bool |
| Waits until the Terminate state has been reached using a relative timeout. | |
| static auto | waitFor (State oldState, const std::chrono::system_clock::duration &timeout, const std::nothrow_t &tag) noexcept -> State |
| Waits until the state differs from a given state using a relative timeout. | |
| static auto | waitUntil (const std::chrono::system_clock::time_point &timeoutTime, const std::nothrow_t &tag) noexcept -> bool |
| Waits until the terminate state has been reached using an absolute timeout. | |
| static auto | waitUntil (State oldState, const std::chrono::system_clock::time_point &timeoutTime, const std::nothrow_t &tag) noexcept -> State |
| Waits until the state differs from a given state using an absolute timeout. | |
| static auto | rethrowException () -> void |
| Rethrows any exception passed to terminate(). | |
Control function | |
| static auto | terminate () noexcept -> void |
| Requests the Terminate state. | |
| static auto | terminate (std::exception_ptr exception) noexcept -> void |
| Requests the Terminate state, causing a single waiter to throw. | |
| static auto | suspend () noexcept -> void |
| Requests the Suspend state. | |
| static auto | resume () noexcept -> void |
| Requests returning to the Run state from the Suspend state. | |
A class that registers handlers that catch termination signals and events.
Under Linux, this class registers and unregisters signal handlers for SIGINT, SIGHUP, and SIGTERM. Under Windows, this class registers a console control handler.
Only one single terminate handler must ever exist at any time. Handlers for Linux signals and Windows console control events will be registered as long as that single instance exists.
|
strong |
| xentara::utils::application::TerminateHandler::TerminateHandler | ( | ConstructorOptions | options = {} | ) |
Constructor that registers the handlers.
| options | The options for the handler |
| std::logic_error | Another termination handler already exists |
| xentara::utils::application::TerminateHandler::~TerminateHandler | ( | ) |
Destructor that unregisters the handlers.
|
staticnoexcept |
Requests returning to the Run state from the Suspend state.
This function does nothing if the state is not State::Suspend
|
static |
Rethrows any exception passed to terminate().
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Requests the Suspend state.
This function does nothing if the state is not State::Run
|
staticnoexcept |
Requests the Terminate state.
|
staticnoexcept |
Requests the Terminate state, causing a single waiter to throw.
This function will wake all waiting threads and cause them to rethrow the given exception. Waiters that passed std::nothrow to the wait function will be woken up, but will not rethrow the exception. Once this function has been called, any subsequent call to a non-std::nothrow wait function will throw.
This function does nothing if the state is already State::Terminate. If any overload of termine() has already been called, the exception is simply discarded.
| exception | The exception that waiters should rethrow |
|
static |
Waits until the Terminate state has been reached.
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Waits until the Terminate state has been reached.
| tag | Always pass std::nothrow as this parameter |
Waits until the state differs from a given state.
This function will wait until the state is no longer oldState.
| oldState | The old state. The wait will finish once the state differs from this state. If the state is already different from oldState when this function is called, then the function will return immediately. oldState must not be State::Terminate, as the state cannot ever leave State::Terminate. |
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Waits until the state differs from a given state.
This function will wait until the state is no longer oldState.
| oldState | The old state. The wait will finish once the state differs from this state. If the state is already different from oldState when this function is called, then the function will return immediately. oldState must not be State::Terminate, as the state cannot ever leave State::Terminate. |
| tag | Always pass std::nothrow as this parameter |
|
static |
Waits until the Terminate state has been reached using a relative timeout.
| timeout | The timeout. |
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Waits until the Terminate state has been reached using a relative timeout.
This function will wait until the Terminate state has been reached, or until a certain amount of time has elapsed.
| timeout | The timeout. |
| tag | Always pass std::nothrow as this parameter |
|
static |
Waits until the state differs from a given state using a relative timeout.
This function will wait until the state is no longer oldState, or until a certain amount of time has elapsed.
| oldState | The old state. The wait will finish once the state differs from this state. If the state is already different from oldState when this function is called, then the function will return immediately. oldState must not be State::Terminate, as the state cannot ever leave State::Terminate. |
| timeout | The timeout. |
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Waits until the state differs from a given state using a relative timeout.
This function will wait until the state is no longer oldState, or until a certain amount of time has elapsed.
| oldState | The old state. The wait will finish once the state differs from this state. If the state is already different from oldState when this function is called, then the function will return immediately. oldState must not be State::Terminate, as the state cannot ever leave State::Terminate. |
| timeout | The timeout. |
| tag | Always pass std::nothrow as this parameter |
|
static |
Waits until the terminate state has been reached using an absolute timeout.
| timeoutTime | The timeout time. |
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Waits until the terminate state has been reached using an absolute timeout.
| timeoutTime | The timeout time. |
| tag | Always pass std::nothrow as this parameter |
|
static |
Waits until the state differs from a given state using an absolute timeout.
This function will wait until the state is no longer oldState, or until a certain timeout time has been reached.
| oldState | The old state. The wait will finish once the state differs from this state. If the state is already different from oldState when this function is called, then the function will return immediately. oldState must not be State::Terminate, as the state cannot ever leave State::Terminate. |
| timeoutTime | The timeout time. |
| Rethrows | any exception passed to terminate() |
|
staticnoexcept |
Waits until the state differs from a given state using an absolute timeout.
This function will wait until the state is no longer oldState, or until a certain timeout time has been reached.
| oldState | The old state. The wait will finish once the state differs from this state. If the state is already different from oldState when this function is called, then the function will return immediately. oldState must not be State::Terminate, as the state cannot ever leave State::Terminate. |
| timeoutTime | The timeout time. |
| tag | Always pass std::nothrow as this parameter |