boost::corosio::signal_set

An asynchronous signal set for coroutine I/O.

Synopsis

class signal_set
    : public io_object

Description

This class provides the ability to perform an asynchronous wait for one or more signals to occur. The signal set registers for signals using sigaction() on POSIX systems or the C runtime signal() function on Windows.

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe. A signal_set must not have concurrent wait operations.

Semantics

Wraps platform signal handling (sigaction on POSIX, C runtime signal() on Windows). Operations dispatch to OS signal APIs via the io_context reactor.

Supported Signals

On Windows, the following signals are supported: SIGINT, SIGTERM, SIGABRT, SIGFPE, SIGILL, SIGSEGV.

Example

signal_set signals(ctx, SIGINT, SIGTERM);
auto [ec, signum] = co_await signals.wait();
if (ec == capy::cond::canceled)
{
    // Operation was cancelled via stop_token or cancel()
}
else if (!ec)
{
    std::cout << "Received signal " << signum << std::endl;
}

Base Classes

Name Description

io_object

Base class for platform I/O objects.

Types

Name

Description

handle

RAII wrapper for I/O object implementation lifetime.

implementation

Forward declaration for platform‐specific implementation.

io_object_impl

Base interface for platform I/O implementations.

io_service

Service interface for I/O object lifecycle management.

signal_set_impl

Enums

Name

Description

flags_t

Flags for signal registration.

Member Functions

Name

Description

signal_set [constructor] [deleted]

Constructors

~signal_set [destructor] [virtual]

Destructor.

operator= [deleted]

Move assignment operator.

add

add overloads

cancel

Cancel all operations associated with the signal set.

clear

Remove all signals from the signal set.

context

Return the execution context.

remove

Remove a signal from the signal set.

wait

Wait for a signal to be delivered.

Protected Data Members

Name

ctx_

impl_

Friends

Name Description

boost::corosio::operator~

Bitwise NOT (complement).

boost::corosio::operator&=

Compound assignment AND.

boost::corosio::operator|=

Compound assignment OR.

boost::corosio::operator&

Mask two flag values.

boost::corosio::operator|

Combine two flag values.

Created with MrDocs