Skip to content

refactor!: remove delay, timeout, and the timer thread; add async_waker#360

Merged
sgerbino merged 1 commit into
cppalliance:develop-2from
sgerbino:pr/timer
Jul 9, 2026
Merged

refactor!: remove delay, timeout, and the timer thread; add async_waker#360
sgerbino merged 1 commit into
cppalliance:develop-2from
sgerbino:pr/timer

Conversation

@sgerbino

@sgerbino sgerbino commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Delete delay(), timeout(), and detail::timer_service, the background timer thread capy spawned per execution_context. Capy no longer creates any thread the user did not ask for; timed operations belong to the I/O layer, which owns a reactor and a clock.

Add async_waker, a single-waiter notification point that replaces the timer thread as the escape hatch: the user provides the thread and the clock, capy provides the suspension point. wake() is callable from any thread and only ever posts through the waiter's executor; a notification with no waiter is latched as a single token so the notify-before-wait race is benign. A three-state atomic is the sole arbiter of the waiter's resume, which makes cross-thread notify safe without locks. wait() requires an executor that resumes continuations on a single thread, the same model as async_event and async_mutex.

The quitter tests and the timeout-cancellation, when-any, and awaitable-sender examples are reworked around the new primitive with std::thread. Also fixes two pre-existing awaitable-sender bugs: a dangling executor_ref bound to a temporary executor, and a discarded symmetric-transfer handle that left a wrapped task never running. error::timeout remains; corosio maps its deadline results onto it.

Related to #351.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.15%. Comparing base (708f0d3) to head (547a6ac).

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##           develop-2     #360      +/-   ##
=============================================
- Coverage      98.29%   98.15%   -0.14%     
=============================================
  Files             79       76       -3     
  Lines           3986     3901      -85     
=============================================
- Hits            3918     3829      -89     
- Misses            68       72       +4     
Flag Coverage Δ
linux 98.15% <ø> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 5 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 708f0d3...547a6ac. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot

cppalliance-bot commented Jul 9, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://360.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-07-09 16:42:59 UTC

Delete delay(), timeout(), and detail::timer_service, the background
timer thread capy spawned per execution_context. Capy no longer
creates any thread the user did not ask for; timed operations belong
to the I/O layer, which owns a reactor and a clock.

Add async_waker, a single-waiter notification point that replaces
the timer thread as the escape hatch: the user provides the thread
and the clock, capy provides the suspension point. wake() is
callable from any thread and only ever posts through the waiter's
executor; a notification with no waiter is latched as a single token
so the notify-before-wait race is benign. A three-state atomic is the
sole arbiter of the waiter's resume, which makes cross-thread notify
safe without locks. wait() requires an executor that resumes
continuations on a single thread, the same model as async_event and
async_mutex.

The quitter tests and the timeout-cancellation, when-any, and
awaitable-sender examples are reworked around the new primitive with
std::thread. Also fixes two pre-existing awaitable-sender bugs: a
dangling executor_ref bound to a temporary executor, and a discarded
symmetric-transfer handle that left a wrapped task never running.
error::timeout remains; corosio maps its deadline results onto it.
@sgerbino sgerbino merged commit 0d3dd90 into cppalliance:develop-2 Jul 9, 2026
37 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 Jul 9, 2026
@sgerbino sgerbino deleted the pr/timer branch July 9, 2026 17:36
@sgerbino sgerbino restored the pr/timer branch July 10, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants