![]() |
TSDuck v3.45-4766
MPEG Transport Stream Toolkit
|
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. | |
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).
|
inlinestatic |
This static function returns whether the Reactor uses an asynchronous I/O model.
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:
|
inlinestatic |
This static function returns whether the Reactor uses a non-blocking I/O model.
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 |
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.
| [in] | sock | A system-specific file descriptor or handle. This can be a socket or something else. |