boost::corosio::signal_set

An asynchronous signal set for coroutine I/O.

Synopsis

class signal_set
    : public io_signal_set

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_signal_set

Abstract base for asynchronous signal sets.

Types

Name

Description

handle

RAII wrapper for I/O object implementation lifetime.

implementation

Define backend hooks for signal set operations.

io_service

Service interface for I/O object lifecycle management.

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 Member Functions

Name

Description

signal_set [constructor]

Construct from handle

operator= [deleted]

Assignment operators

do_cancel [virtual]

Dispatch cancel to the concrete implementation.

Protected Static Member Functions

Name

Description

create_handle

Create a handle bound to a service found in the context.

Protected Data Members

Name

Description

h_

The platform I/O handle owned by this object.

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.

Derived Classes

Name

Description

native_signal_set

An asynchronous signal set with devirtualized wait operations.

Created with MrDocs