Repository navigation
Add async support via AsyncExecutor runtime - #7
Closed
alan-george-lk wants to merge 19 commits into
Closed
alan-george-lk wants to merge 19 commits into
alan-george-lk wants to merge 19 commits into
Conversation
Use AsyncExecutor throughout the generated bindings. Keep shutdown idempotent, free rejected Rust handles once, and deliver callback and value-transfer failures through the future lifecycle. Generate async record and enum methods, cover executor and FFI behavior with focused tests, and replace benchmark output with functional assertions. Document the runtime and its UniFFI contract.
Link the Windows synchronization library for the Rust fixtures and include the string declarations used by async bindings and tests.
Retain the shared executor for process lifetime and keep explicit shutdown available. Verify exit from a continuation and exit with pending Rust futures in separate test processes.
Serialize restart with shutdown and keep operation IDs monotonic. Prevent retired callbacks from starting in a subsequent run, and verify restarted workers and Rust callback round trips.
Keep a copy of the weak cancellation action so another thread can cancel a blocking get or a future transferred into then. Test the handle after completion and destruction of the owning future.
Closing admission can reject a queued C++ callback before shutdown reaches the Rust call that awaits it. Send cancellation before the next poll and preserve completion for futures that already signaled READY. Exercise the ordering with a queued callback and a paused shutdown cancellation in the executor fixture.
Explain how UniFFI lifts a callback cancellation and how a Rust trait method can convert it into its declared error. Clarify where applications may invoke the completion callbacks.
Hold the worker until admission closes and pause shutdown before per-call cancellation. Verify that the outer call receives AsyncCancelledError.
Document callback rejection after shutdown and link to the complete UniFFI error conversion macro.
Complete ready futures inline and keep pending work on the executor. Share the driver across exports, cover Rust-backed traits and callbacks from Tokio, and reuse the upstream futures fixture.
GCC emits the included binding's vtable initializers. Use the futures binding already linked by this test.
Queue new first polls on the worker while shutdown waits for inline polls. Cover callback startup during the wait and cancellation after the poll returns.
alan-george-lk
commented
Nov 23, 2026
| // block. | ||
| class AsyncExecutor { | ||
| public: | ||
| AsyncExecutor() : worker_([this] { run(); }) {} |
Collaborator
Author
There was a problem hiding this comment.
Reviewer note: only one worked thread was needed in testing (data tracks, integration/stress testing on C++ SDK). Can increase this to a fixed-size pool if we run into issues with this as other features get migrated over
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.
This PR is a fairly hefty set of changes to enable
asyncsupport. As C++ has no nativeasyncruntime, one had to be created.AsyncExecutoris a class/singleton environment that is created lazily on the firstasynccall, or whose lifecycle can be explicitly controlled via API. Presently, this is implemented with only a single worker thread, but was sufficient in all testing that I threw at it. A small thread pool (say ~4 threads by default) was considered, and can easily be implemented later, but did not seem required so far even under the heaviest loads.I vetted this through: