Skip to content

Async support: Add async executor - #8

Open
alan-george-lk wants to merge 2 commits into
livekit/devfrom
livekit/dev-async-executor
Open

alan-george-lk wants to merge 2 commits into
livekit/devfrom
livekit/dev-async-executor

Conversation

@alan-george-lk

@alan-george-lk alan-george-lk commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part 1 of the C++ async support stack.

Context: The UniFFI documentation on async states that UniFFI relies on the foreign languages async runtime. As C++ does not have a native runtime, a AsyncExecutor is added with a single worker thread.

AsyncExecutor is a class/singleton environment that is created lazily on the first async call, 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.

Testing

I vetted this entire stack through:

  • New unit/integration tests within the bindgen for async generated code and executor runtime edges (lifecycle, thread safety, etc.)
  • Replacing data tracks within the C++ SDK with this implementation, while changing no unit/integration tests (solid coverage there), and everything passed
  • Lengthy agent sessions where regression testing was constantly evaluated after each major change

@alan-george-lk
alan-george-lk added this pull request to stack #12 November 23, 2026 23:17
@alan-george-lk
alan-george-lk marked this pull request as ready for review November 23, 2026 23:18
@alan-george-lk alan-george-lk changed the title Add the shared C++ async executor Async support: Add async executor Nov 23, 2026
// Wakes shutdown to recheck its first-poll and drain conditions.
std::condition_variable drained_;
// Holds tasks in the order the worker will run them.
std::deque<AsyncTask> tasks_;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up on timeouts for work taking too long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant