Skip to content

docs: document the early quitter and the other example programs - #483

Merged
sgerbino merged 12 commits into
cppalliance:developfrom
TheLingeringWill:pr/document-toolkit-examples-quitter
Nov 13, 2026
Merged

sgerbino merged 12 commits into
cppalliance:developfrom
TheLingeringWill:pr/document-toolkit-examples-quitter

Conversation

@TheLingeringWill

@TheLingeringWill TheLingeringWill commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #409. Part of #416.

The Boost review asked why the quitter and the other toolkit pieces ship if the manual does not document them. #481 moved the quitter out of the library into example/early-quitter. This PR documents it, and the rest of example/, in the manual. Every example program now has a page or a row in a table. The manual also states that example code is not part of Capy.

New pages

  • 4l, Synchronization Primitives (4.coroutines/4l.synchronization.adoc): when to use a strand, async_mutex, async_event, or async_waker. It covers how each one treats a stop, what destruction does to its waiters, and the threading model. It includes tagged regions that already exist in the examples and snippets, so it adds no snippet file.
  • 8r, Writing Your Own Task Type (Early Quitter) (8.examples/8r.early-quitter.adoc): a walkthrough of main.cpp, with quitter.hpp and shutdown.cpp in collapsible blocks. It covers when to use the quitter instead of task, the two cases of the stop rule, what each check in checks.cpp covers, and the known limitations. It says the quitter is example code (feat!: move quitter out of the library into an example #481, quitter's place in the library #431), and that task is Capy's only task type.
  • 8t, Using a Capy Stream from Asio (8.examples/8t.asio-callbacks.adoc): asio_callbacks.cpp and its uni_stream adapter, the opposite direction of 8p.

Changes to existing pages

  • 8.intro: a "Library Code and Example Code" section, entries for 8r and 8t, and an "Other Programs in the Repository" table for the examples without a page.
  • example/README.md: rewritten as an index of every example directory, split between the programs the manual teaches and the others, with their build flags. Drops the stale stream-pipeline/ entry.
  • nav.adoc: the three new pages and the new table.
  • 4f: a TIP that points to 8r. The when_any sentence now says losing tasks are cancelled when the first task succeeds, not when it completes, and links 8f.
  • 4j: the sentence on destroying a primitive is split in two and links the new destruction rules in 4l.
  • Links to the new pages from 4e, the glossary, the index, 8p, and the Next Steps of 8b, 8f, and 8l.
  • Drive-by: 4.intro gains its missing 4j entry.

Add 4l, one conceptual home for async_mutex, async_event and
async_waker: choosing between them and a strand, the shared threading
model, the cancellation and destruction rules, and allocation. The page
shows existing tagged regions only.

Link it from the glossary entries, the 4j destruction paragraph (split
into shorter sentences), and the Next Steps of 8b, 8f and 8l.
Add 8r, which documents example/early-quitter as a user-written task
type: when to use it instead of task, the signal-to-stop pattern, how
a stop ends a run of quitters, results that race a stop, the boundary
rule, cleanup after the completion handler, the self-checks and the
known limitations. It keeps the still-valid rationale of the deleted
doc/quitter.md.

Link it from 4e and from a TIP in 4f, and say in 4f that when_any
cancels the losers when the first task succeeds.
Add 8t, which walks through asio_callbacks.cpp and the uni_stream
adapter built on async_initiate. Point 8p's note and See Also at 8t and
at the 9n section that covers any_stream.cpp.
Add 4l, 8t and 8r to the nav, the chapter intros and the index. In
8.intro, state that example code is not Capy API, correct the claim
that every example is self-contained, and add a table of the programs
that have no page, with a nav entry. when-any-cancellation is listed
as out of date.

Rewrite example/README.md as an index of all 24 example directories.
Also add the missing 4j entry to 4.intro.
- 4l: the lock error code covers every cancellation, the shutdown
  callout no longer relies on a declaration outside the include, and
  the allocation rule notes that posting a waiter may allocate.
- 8r: place the asynchronous stop race before the gate runs, say that
  the shutdown output omits its latency line, and drop the note that
  went beyond the two ideas kept from doc/quitter.md.
- 8.intro: link any_stream.cpp itself, and do not link the out-of-date
  when-any-cancellation directory.
- 8p: link the 9n section on any_stream.cpp from See Also.
- example/README.md: any-sender-size counts the allocations of both
  connect and start.
carries_stop has no cv-qualified forms, so a const result cannot carry
the stop and is dropped like a reference result; it is not moved.

Also: 4l no longer suggests waking a waker from a signal handler, 8r
says to copy shutdown.cpp's order instead of calling main.cpp's order
safe, 8t says capy_streams.hpp declares rather than defines, and the
CUDA rows name the C++20 requirement.
The pool is declared before the strands and wakers, so its joining
destructor runs after them and cannot be the reason. The reasons are
that each run_async call keeps its own copy of its strand, sharing one
reference-counted state, and that a claimed waiter never touches its
waker again.

Also: the gate is created when an awaited operation is first not
ready, 8t says that b2 builds the asio examples unconditionally and
that the two chains can interleave differently, and the any-sender-size
row matches the README.
BOOST_CAPY_BUILD_CUDA_EXAMPLES adds all four cuda/ programs, and
cuda/pipeline fails to configure without BOOST_CAPY_BUILD_NVEXEC_EXAMPLES,
which needs BOOST_CAPY_BUILD_STDEXEC_EXAMPLES and C++23. Say so under
the 8.intro table and in example/README.md.

Also: 4l says unlock() skips waiters a stop already claimed and that
the shutdown snippet's one-thread pool meets the threading rule; 8r
draws the stop transfer from the gate straight to run_async and no
longer says inner quitters may use any result type.
@cppalliance-bot

cppalliance-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

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

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

2026-11-12 00:30:10 UTC

@cppalliance-bot

cppalliance-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

GCOVR code coverage report https://483.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://483.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://483.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-11-12 00:42:03 UTC

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (811054a) to head (d72c2a5).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #483      +/-   ##
===========================================
+ Coverage    98.45%   98.46%   +0.01%     
===========================================
  Files          135      135              
  Lines         7250     7250              
===========================================
+ Hits          7138     7139       +1     
+ Misses         112      111       -1     
Flag Coverage Δ
linux 98.46% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file 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 811054a...d72c2a5. Read the comment docs.

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

@TheLingeringWill
TheLingeringWill force-pushed the pr/document-toolkit-examples-quitter branch from cf563c3 to d355a4a Compare November 10, 2026 23:55
@TheLingeringWill
TheLingeringWill marked this pull request as ready for review November 11, 2026 00:20
@sgerbino
sgerbino merged commit 25299eb into cppalliance:develop Nov 13, 2026
40 of 41 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 Nov 13, 2026
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.

docs: document quitter and the other toolkit examples in the manual

3 participants