Add Async Handlers Support#112
Open
g41797 wants to merge 26 commits into
Open
Conversation
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.
Async handlers ("split" handlers) are based on the already existing async body reading flow
Split Handler Pattern
One handler proc, called twice:
res.work_data - shared data between two calls
Flow (includes body reading)
"Async" Changes
New:
Modified:
server.odin
Non-Async Changes
conn_handle_req does nothing when
closingis set, it allows safe close and prevents SIGBUS (macOS) and memory leaks (Windows):Sometimes the server hung during shutdown — added 1ms timeout to nbio.tick().
Examples
examples/async/ — three examples
All use thread.create per request (for illustration only)
Production code should use a worker pool or pipeline
Known problems
Docs generation on GitHub failed - Odin version dev-2026-04-nightly:0c9ea9b
Local generation - ok - Odin version dev-2026-03-nightly