Wrapper for an asynchronous handle supporting cancellation and closure.
More...
#include <cancelable_handle.hpp>
|
| CancelableHandle (openvpn_io::io_context &io_context) |
| Constructs with the given I/O context.
|
|
| ~CancelableHandle () |
| Destructor ensures handle cancellation and closure.
|
|
void | check_is_already_signalled () |
| Checks if the handle's event is already signaled.
|
|
void | cancel_and_close () |
| Cancels and closes the handle if not already closed.
|
|
void | assign (HANDLE handle) |
| Assigns a native Windows handle.
|
|
template<typename Handler > |
void | async_wait (Handler &&handler) |
| Initiates an asynchronous wait on the handle.
|
|
|
openvpn_io::windows::object_handle | handle_ |
| Asynchronous Windows object handle.
|
|
std::shared_ptr< bool > | is_closed_ = std::make_shared<bool>(false) |
| Indicates if handle is closed.
|
|
Wrapper for an asynchronous handle supporting cancellation and closure.
Automatically manages lifecycle by canceling and closing the handle if not already done.
Definition at line 22 of file cancelable_handle.hpp.
◆ CancelableHandle()
openvpn::CancelableHandle::CancelableHandle |
( |
openvpn_io::io_context & |
io_context | ) |
|
|
inline |
Constructs with the given I/O context.
- Parameters
-
io_context | I/O context for asynchronous operations. |
Definition at line 29 of file cancelable_handle.hpp.
◆ ~CancelableHandle()
openvpn::CancelableHandle::~CancelableHandle |
( |
| ) |
|
|
inline |
◆ assign()
void openvpn::CancelableHandle::assign |
( |
HANDLE |
handle | ) |
|
|
inline |
Assigns a native Windows handle.
- Parameters
-
handle | The native HANDLE to manage. |
Definition at line 84 of file cancelable_handle.hpp.
◆ async_wait()
template<typename Handler >
void openvpn::CancelableHandle::async_wait |
( |
Handler && |
handler | ) |
|
|
inline |
Initiates an asynchronous wait on the handle.
- Parameters
-
handler | Handler executed on completion, unless closed. |
Definition at line 95 of file cancelable_handle.hpp.
◆ cancel_and_close()
void openvpn::CancelableHandle::cancel_and_close |
( |
| ) |
|
|
inline |
◆ check_is_already_signalled()
void openvpn::CancelableHandle::check_is_already_signalled |
( |
| ) |
|
|
inline |
Checks if the handle's event is already signaled.
- Exceptions
-
Exception | if event is signaled or abandoned, or on WaitForSingleObject failure. |
Definition at line 44 of file cancelable_handle.hpp.
◆ handle_
openvpn_io::windows::object_handle openvpn::CancelableHandle::handle_ |
|
private |
◆ is_closed_
std::shared_ptr<bool> openvpn::CancelableHandle::is_closed_ = std::make_shared<bool>(false) |
|
private |
The documentation for this class was generated from the following file: