OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::CancelableHandle Class Reference

Wrapper for an asynchronous handle supporting cancellation and closure. More...

#include <cancelable_handle.hpp>

Public Member Functions

 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.
 

Private Attributes

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CancelableHandle()

openvpn::CancelableHandle::CancelableHandle ( openvpn_io::io_context &  io_context)
inline

Constructs with the given I/O context.

Parameters
io_contextI/O context for asynchronous operations.

Definition at line 29 of file cancelable_handle.hpp.

◆ ~CancelableHandle()

openvpn::CancelableHandle::~CancelableHandle ( )
inline

Destructor ensures handle cancellation and closure.

Definition at line 35 of file cancelable_handle.hpp.

Member Function Documentation

◆ assign()

void openvpn::CancelableHandle::assign ( HANDLE  handle)
inline

Assigns a native Windows handle.

Parameters
handleThe native HANDLE to manage.

Definition at line 84 of file cancelable_handle.hpp.

Here is the caller graph for this function:

◆ async_wait()

template<typename Handler >
void openvpn::CancelableHandle::async_wait ( Handler &&  handler)
inline

Initiates an asynchronous wait on the handle.

Parameters
handlerHandler executed on completion, unless closed.

Definition at line 95 of file cancelable_handle.hpp.

Here is the caller graph for this function:

◆ cancel_and_close()

void openvpn::CancelableHandle::cancel_and_close ( )
inline

Cancels and closes the handle if not already closed.

Definition at line 62 of file cancelable_handle.hpp.

Here is the caller graph for this function:

◆ check_is_already_signalled()

void openvpn::CancelableHandle::check_is_already_signalled ( )
inline

Checks if the handle's event is already signaled.

Exceptions
Exceptionif event is signaled or abandoned, or on WaitForSingleObject failure.

Definition at line 44 of file cancelable_handle.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ handle_

openvpn_io::windows::object_handle openvpn::CancelableHandle::handle_
private

Asynchronous Windows object handle.

Definition at line 106 of file cancelable_handle.hpp.

◆ is_closed_

std::shared_ptr<bool> openvpn::CancelableHandle::is_closed_ = std::make_shared<bool>(false)
private

Indicates if handle is closed.

Definition at line 107 of file cancelable_handle.hpp.


The documentation for this class was generated from the following file: