xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::windows::OverlappedResult Class Referencefinal

The result of an overlapped operation that used extra wait objects. More...

#include <xentara/utils/windows/OverlappedResult.hpp>

Public Member Functions

constexpr OverlappedResult () noexcept=default
 Default constructor.
 
constexpr auto wasInterrupted () const noexcept -> bool
 checks if the operation was interrupted by one of the higher number wait objects
 
constexpr auto waitObjectIndex () const noexcept -> std::size_t
 Returns the index of the wait object that was triggered.
 
constexpr auto numberOfBytesTransferred () const noexcept -> DWORD
 Returns the number of bytes transferred.
 

Static Public Member Functions

static constexpr auto completed (DWORD numberOfBytesTransferred=0) noexcept -> OverlappedResult
 Constructs a synthetic operlapped result for a completed operation.
 
static constexpr auto interrupted (std::size_t waitObjectIndex) noexcept -> OverlappedResult
 Constructs a synthetic operlapped result for an interrupted operation.
 

Detailed Description

The result of an overlapped operation that used extra wait objects.

Note
This class is only available under Windows
See also
windows::Handle::performOverlappedIo(functional::function_ref<auto(HANDLE, OVERLAPPED *) → BOOL>, std::span<HANDLE>, std::optional<std::chrono::nanoseconds>) "windows::Handle::performOverlappedIo()"
windows::Socket::performOverlappedIo(functional::function_ref<auto(SOCKET, OVERLAPPED *) → BOOL>, std::span<HANDLE>, std::optional<std::chrono::nanoseconds>) "windows::Socket::performOverlappedIo()"
network::Socket::performOverlappedIo(functional::function_ref<auto(SOCKET, OVERLAPPED *) → BOOL>, std::span<HANDLE>, std::optional<std::chrono::nanoseconds>) "network::Socket::performOverlappedIo()"

Constructor & Destructor Documentation

◆ OverlappedResult()

constexpr xentara::utils::windows::OverlappedResult::OverlappedResult ( )
constexprdefaultnoexcept

Default constructor.

This constructor creates an object with wait object index 0 and 0 bytes transferred.

Member Function Documentation

◆ completed()

static constexpr auto xentara::utils::windows::OverlappedResult::completed ( DWORD  numberOfBytesTransferred = 0) -> OverlappedResult
staticconstexprnoexcept

Constructs a synthetic operlapped result for a completed operation.

This function can be used to construct a dummy result objects that is not actually the result of an overlapped operation.

Parameters
numberOfBytesTransferredThe number of bytes transferred.

◆ interrupted()

static constexpr auto xentara::utils::windows::OverlappedResult::interrupted ( std::size_t  waitObjectIndex) -> OverlappedResult
staticconstexprnoexcept

Constructs a synthetic operlapped result for an interrupted operation.

This function can be used to construct a dummy result objects that is not actually the result of an overlapped operation.

Parameters
waitObjectIndexThe index of the wait object that was triggered. Must not be 0.

◆ numberOfBytesTransferred()

constexpr auto xentara::utils::windows::OverlappedResult::numberOfBytesTransferred ( ) const -> DWORD
constexprnoexcept

Returns the number of bytes transferred.

Returns
The number of bytes trasferred, as reported by the overlapped operation. The exact meaning of this member depends on the type of overlapped operation. See the documentation of the lpNumberOfBytesTransferred parameter of GetOverlappedResult().

If wasInterrupted() returns true, then this member will always be zero, because the operation did not complete.

◆ waitObjectIndex()

constexpr auto xentara::utils::windows::OverlappedResult::waitObjectIndex ( ) const -> std::size_t
constexprnoexcept

Returns the index of the wait object that was triggered.

Returns
The index of the wait object that was triggered. The index will be 0 if the operation was completed, because the first object in the list of wait objects passed to Handle::performOverlappedIo(functional::function_ref<auto(HANDLE, OVERLAPPED *) → BOOL>, std::span<HANDLE>, std::optional<std::chrono::nanoseconds>) "performOverlappedIo()" is used as the event in the OVERLAPPED structure.

◆ wasInterrupted()

constexpr auto xentara::utils::windows::OverlappedResult::wasInterrupted ( ) const -> bool
constexprnoexcept

checks if the operation was interrupted by one of the higher number wait objects

This function is equivalent to calling waitObjectIndex() > 0. If you passed more than two wait objects to Handle::performOverlappedIo(functional::function_ref<auto(HANDLE, OVERLAPPED *) → BOOL>, std::span<HANDLE>, std::optional<std::chrono::nanoseconds>) "performOverlappedIo()", you can determine the exact index of the object triggered using waitObjectIndex().

Returns
Returns true if the wait object index is greater than 0, or false if it is 0.