P0876R22 — fiber_context - fibers without scheduler
(10 items)
LEWG, LWG, CWG
This paper proposes a minimal API, std::fiber_context, that enables stackful symmetric context switching without requiring a scheduler. The design avoids global variables by synthesizing and passing fiber_context objects representing suspended fibers, mandates per-fiber exception state for std::uncaught_exceptions() and std::current_exception(), and provides the low-level building block upon which higher-level facilities such as coroutines, cooperative multitasking, and generators can be constructed. Full standard wording is provided targeting inclusion in C++29.
-
Section 32.12.3.1 [fiber.context.cons], span constructor Effects clause — std::forward
(deleter) uses wrong template parameter; deleter has type D&&, so it should be std::forward (deleter). [1] [1] - Section 32.12.2 [fiber.context.syn] — Stable name [fibercontext] in the header synopsis cross-reference does not match any section defined in the paper; the class definition lives in [fiber.context.class]. [2] [2]
- Section "returning synthesized fiber_context object from resume()", filament example — The resume_with() call is missing its closing parenthesis and semicolon after the lambda body; the expression is never terminated. [3]
- Section "asymmetric fiber", prose after code block — Prose says "at line 16" for f1.resume(), but f1.resume() is line 17 in the numbered listing; reference is off by one. [6] [4]
- Section "asymmetric fiber", prose after code block — Prose says "At line 2" for self::suspend() inside f4, but self::suspend() is line 3; reference is off by one. [7] [5]
- Section 32.12.3.1 [fiber.context.cons], unary constructor paragraph 6 — Missing space between "Error conditions:" and "resource_unavailable_try_again". [3] [6]
- Section 32.12.3.1 [fiber.context.cons], span constructor paragraph 6 — Missing space between "Error conditions:" and "resource_unavailable_try_again". [4] [7]
- Section 32.12.3.1 [fiber.context.cons], move assignment operator — Missing space between "Returns:" and "*this". [5] [8]
References — Anthropic Citations API
[1]
chars 100401–100524
"— end note ] — Let deleter_copy be an object of type decay_t direct-non-list-initialized with std::forward(deleter).
"
"— end note ] — Let deleter_copy be an object of type decay_t
[2]
"void resume_next( filament& fila){ std::move(fila.f_).resume_with([this](fiber_context&& f)->fiber_context{ f_=std::move(f); return {}; } }"
"void resume_next( filament& fila){ std::move(fila.f_).resume_with([this](fiber_context&& f)->fiber_context{ f_=std::move(f); return {}; } }"
[3]
chars 97359–98599
"32.12.2 Header synopsis
[fiber.context.syn]
namespace std {
// [fibercontext], class fiber_context
class fiber_context;
}
33
32.12.3 Class..."
"32.12.2 Header
[3]
chars 97359–98599
"32.12.2 Header synopsis
[fiber.context.syn]
namespace std {
// [fibercontext], class fiber_context
class fiber_context;
}
33
32.12.3 Class..."
"32.12.2 Header
[4]
chars 99551–99671
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
[4]
chars 101345–101465
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
[5]
chars 99551–99671
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
[5]
chars 101345–101465
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
"6 Error conditions:resource_unavailable_try_again – the system lacked the necessary resources to prepare another fiber. "
[6]
chars 101876–102069
"2 Returns:*this 32.12.3.2 Members [fiber.context.mem] template fiber_context resume_with(Fn&& fn) &&
;
The operation of resume_with() involves at least two and possibly three fibers. "
"2 Returns:*this 32.12.3.2 Members [fiber.context.mem] template
[7]
chars 42646–43131
"f1 f1.resume() f2 f3 f4 f2.resume() self::suspend() f3.resume() self::suspend() f4.resume() self::suspend() 1 // hypothetical API 2 fiber_context f4{[]{ 3 self::suspend(); 4 }}; 5 fiber_context..."
"f1 f1.resume() f2 f3 f4 f2.resume() self::suspend() f3.resume() self::suspend() f4.resume() self::suspend() 1 // hypothetical API 2 fiber_context f4{[]{ 3 self::suspend(); 4 }}; 5 fiber_context..."
[8]
chars 43179–43243
"At line 2 fiber f4 calls its suspend operation self::suspend(). "
"At line 2 fiber f4 calls its suspend operation self::suspend(). "
Summary: P0876R22 proposes std::fiber_context, a low-level stackful context-switching primitive for C++ with no built-in scheduler, intended as a building block for coroutine and fiber libraries. The paper provides standard wording placing fiber_context in [thread] and includes motivating examples for symmetric, asymmetric, and generator-style fibers.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.