Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,13 @@ jobs:
--warnings-as-errors='*'
- name: FlameGraph
uses: alandefreitas/cpp-actions/flamegraph@v1.9.0
uses: alandefreitas/cpp-actions/flamegraph@v1.9.5
if: matrix.time-trace
continue-on-error: true
with:
source-dir: corosio-root
build-dir: corosio-root/__build__
github_token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Coverage Report
if: ${{ matrix.coverage && matrix.linux }}
Expand Down
31 changes: 31 additions & 0 deletions include/boost/corosio/signal_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <concepts>
#include <system_error>
#include <type_traits>

/*
Signal Set Public API
Expand Down Expand Up @@ -224,6 +225,36 @@ class BOOST_COROSIO_DECL signal_set : public io_signal_set
(check(add(signals)), ...);
}

/** Construct an empty signal set from an executor.

The signal set is associated with the executor's context.

@param ex The executor whose context will own this signal set.
*/
template<class Ex>
requires(!std::same_as<std::remove_cvref_t<Ex>, signal_set>) &&
capy::Executor<Ex>
explicit signal_set(Ex const& ex) : signal_set(ex.context())
{
}

/** Construct a signal set with initial signals from an executor.

The signal set is associated with the executor's context.

@param ex The executor whose context will own this signal set.
@param signal First signal number to add.
@param signals Additional signal numbers to add.

@throws std::system_error Thrown on failure.
*/
template<class Ex, std::convertible_to<int>... Signals>
requires capy::Executor<Ex>
signal_set(Ex const& ex, int signal, Signals... signals)
: signal_set(ex.context(), signal, signals...)
{
}

/** Move constructor.

Transfers ownership of the signal set resources.
Expand Down
18 changes: 18 additions & 0 deletions test/unit/signal_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ struct signal_set_test
BOOST_TEST_PASS();
}

void testConstructFromExecutor()
{
io_context ioc(Backend);
signal_set s(ioc.get_executor());

BOOST_TEST_PASS();
}

void testConstructFromExecutorWithSignals()
{
io_context ioc(Backend);
signal_set s(ioc.get_executor(), SIGINT, SIGTERM);

BOOST_TEST_PASS();
}

void testMoveConstruct()
{
io_context ioc(Backend);
Expand Down Expand Up @@ -795,6 +811,8 @@ struct signal_set_test
testConstructWithOneSignal();
testConstructWithTwoSignals();
testConstructWithThreeSignals();
testConstructFromExecutor();
testConstructFromExecutorWithSignals();
testMoveConstruct();
testMoveAssign();
testMoveAssignCrossContext();
Expand Down
Loading