Continuation zero alloc enqueue#305
Merged
sgerbino merged 3 commits intoJul 2, 2026
Merged
Conversation
capy removed the DynamicBuffer concept, string_dynamic_buffer, and read_until, so several corosio targets no longer compile against the current capy. Migrate them to the fixed-buffer read primitives: - tcp_socket unit test: read a fixed number of bytes into a mutable_buffer instead of a string_dynamic_buffer. - http-client and https-client examples: read the response until EOF one fixed chunk at a time. - corosio http_server benchmark: a local read_until helper scans for the header delimiter over single reads, preserving the previous read-until semantics.
|
An automated preview of the documentation is available at https://305.corosio.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-07-02 21:18:57 UTC |
108b4ae to
f51ea86
Compare
Posting a capy::continuation no longer recovers an enclosing continuation_op through offset-based pointer arithmetic and a magic tag. That recovery read out of bounds whenever a bare continuation (one not embedded in a continuation_op) was posted. The bare continuation is now the unit that is enqueued directly, so the read is gone. A new detail::ready_queue is a single intrusive FIFO that carries both scheduler_ops and capy::continuations, distinguished by a low tag bit on each queue entry. The bit is stolen from the guaranteed-zero low bit of an aligned pointer and decoded with std::bit_cast, so there is no integer-to-pointer cast and no strict-aliasing violation. A scheduler_op links through a uintptr_t q_next_ that reuses its former padding word; a continuation links through capy's reserved slot. The scheduler gains a post(capy::continuation&) overload that enqueues the continuation with no heap allocation. The reactor, io_uring, and IOCP ready paths all carry continuations. Each drain loop decodes the tag and either resumes the coroutine handle or dispatches the op; each shutdown drain destroys the coroutine frame instead of resuming it. IOCP routes a continuation through the completion port under a dedicated key_continuation key. Posted coroutines resume without memory fences: every ready-queue publish and pop is ordered by the scheduler's mutex, and on IOCP by the completion port's kernel transition, so the cross-thread handoff is fully visible to ThreadSanitizer. continuation_op is removed; every embedder now stores a bare capy::continuation directly. Unit tests cover the ready_queue ordering, a worst-case-layout reproducer for the former out-of-bounds read, and a counting-operator- new assertion that the reactor and io_uring post paths allocate nothing.
The capy checkout pinned every ref except master to capy develop, so branches tracking a different capy line, such as develop-2, built against a mismatched dependency. A resolve step now picks the first capy branch whose name matches the build: the pull request's source, then its target, then the pushed branch, falling back to capy's default branch. Trigger filters use a develop* glob so develop-2 pushes and pull requests run CI, docs, and coverage. The boost and asio checkouts are unchanged; neither tracks a develop-2 line.
f51ea86 to
489ff05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #290.