TSDuck v3.45-4766
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ReactorSupport Class Reference

Define which kind of implementation and support are provided for reactors. More...

#include <tsReactorSupport.h>

Static Public Member Functions

static bool SupportedDevice (SysSocketType sock)
 Check if a given file descriptor or handle is supported by the reactor.
 
static consteval bool UseAsynchronousIO ()
 This static function returns whether the Reactor uses an asynchronous I/O model.
 
static consteval bool UseNonBlockingIO ()
 This static function returns whether the Reactor uses a non-blocking I/O model.
 

Detailed Description

Define which kind of implementation and support are provided for reactors.

This class contains static methods only, some of them being consteval (compilation-level checks).

Member Function Documentation

◆ UseAsynchronousIO()

static consteval bool ts::ReactorSupport::UseAsynchronousIO ( )
inlinestatic

This static function returns whether the Reactor uses an asynchronous I/O model.

Returns
True when asynchronous I/O are used, false when non-blocking I/O are used.

Reactive classes which manage I/O shall start I/O operations and, if the operation completes with a "pending" status, the reactive class shall request the Reactor to be notified when the I/O completes. In the meantime, the reactive class shall ensure that the I/O buffers remain valid, as they are used in the background by the I/O.

This method is typically used in "if constexpr" structures, which are preferred to conditional compilation using the macro TS_USE_ASYNCHRONOUS_IO.

Example:

....
}
static consteval bool UseAsynchronousIO()
This static function returns whether the Reactor uses an asynchronous I/O model.
Definition tsReactorSupport.h:112
See also
UseNonBlockingIO()
NonBlockingDevice

◆ UseNonBlockingIO()

static consteval bool ts::ReactorSupport::UseNonBlockingIO ( )
inlinestatic

This static function returns whether the Reactor uses a non-blocking I/O model.

Returns
True when non-blocking I/O are used, false when asynchronous I/O are used.

Reactive classes which manage I/O shall repeatedly attempt I/O operations as long as they succeed. When they fail with a "would block" status, the reactive class shall request the Reactor to be notified when the I/O becomes possible.

This method is typically used in "if constexpr" structures, which are preferred to conditional compilation using the macro TS_USE_NON_BLOCKING_IO.

Example:

....
}
static consteval bool UseNonBlockingIO()
This static function returns whether the Reactor uses a non-blocking I/O model.
Definition tsReactorSupport.h:143
See also
UseAsynchronousIO()
NonBlockingDevice

◆ SupportedDevice()

static bool ts::ReactorSupport::SupportedDevice ( SysSocketType  sock)
static

Check if a given file descriptor or handle is supported by the reactor.

On some operating systems, some types of devices do not support asynchronous or non-blocking I/O and cannot be used in a reactor. The most annoying case is regular files on Linux. Using a regular file with epoll on Linux ends with EPERM because regular files are considered as "always ready". On macOS and FreeBSD, regular files are also "always ready" but they can be used by kqueue, which means that the code can be generic, which is not the case on Linux.

Parameters
[in]sockA system-specific file descriptor or handle. This can be a socket or something else.
Returns
True if sock supports asynchronous or non-blocking I/O on this operating system, false otherwise.

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