xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::io::StopSource Class Reference

A class that allows interrupting wait operations on communications classes. More...

#include <io/StopSource.hpp>

+ Inheritance diagram for xentara::utils::io::StopSource:

Public Member Functions

internal auto requestStop () -> void
 Requests all associated operations to stop.
 
auto reset () -> void
 Resets the object so that is can be used again.
 
auto handle () const noexcept -> HANDLE
 Returns a handle that can be used to wait for the stop source to be triggered.
 
auto pollFd () const noexcept -> ::pollfd
 Creates a pollfd structure that can be used to wait for the stop source to be triggered.
 

Detailed Description

A class that allows interrupting wait operations on communications classes.

This class allows interruption of blocking wait functions on communication classes like ipc::NamedPipe. This is normally done so that the device can be closed and the service stopped when the application is shut down. The methods of the communications class that are affected by the stop source will throw an exception of type io::StopRequested if a stop is requested while they run, or has been requested before thay ran.

Member Function Documentation

◆ handle()

auto xentara::utils::io::StopSource::handle ( ) const -> HANDLE
noexcept

Returns a handle that can be used to wait for the stop source to be triggered.

The returned handle is suitable for use in functions like WaitForSingleObject or WaitForMultipleObjects.

Note
This function is only available under Windows.

◆ pollFd()

auto xentara::utils::io::StopSource::pollFd ( ) const -> ::pollfd
noexcept

Creates a pollfd structure that can be used to wait for the stop source to be triggered.

The returned structure can be used in poll() to wait for the stop request.

Note
This function is not available under Windows.

◆ requestStop()

internal auto xentara::utils::io::StopSource::requestStop ( ) -> void

Requests all associated operations to stop.

Affected functions will throw an exception of type io::StopRequested.

◆ reset()

auto xentara::utils::io::StopSource::reset ( ) -> void

Resets the object so that is can be used again.

Precondition
This function must not be called while any interruptible operations are in progress.