Repository navigation
feat(coro): context interface, strand, exact current context - #23
Closed
codethinki wants to merge 1 commit into
Closed
codethinki wants to merge 1 commit into
codethinki wants to merge 1 commit into
Conversation
- context: the interface of scheduler and strand (post, await, owns_thread), executor, payloads and awaiters take context const& - strand: serial queue on the workers of a scheduler, jobs run one at a time in post order - context::current(): the context of the job on this thread, schedule_awaiter and spawn decide with it - scheduler -> context renames in the payload, the executor, the awaiters and the this_coro tag - asio helpers once in src/utility/asio/ops.hpp, the macro in asio/macro.hpp
Owner
Author
|
Replaced by #25. |
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.
A strand for cth_coro: a serial queue on the workers of a scheduler. jvk needs one per Vulkan queue, so submits of one queue never run at the same time, without a thread per queue.
context
cth::co::context:post(),await(handle),await(time point),owns_thread()andcurrent(). Protected non-virtual destructor.schedulerandstrandimplement it, bothfinal.executor, the payload, the awaiters and the this_coro tag takecontext const&instead ofscheduler const&.scheduler_payload->context_payload,payload.scheduler()->payload.context(),rebind_scheduler()->rebind_context(),this_coro::scheduler->this_coro::context,executor::scheduler()->executor::context().strand
explicit strand(scheduler const&): its jobs run one at a time and in post order, on the workers of the scheduler. The scheduler outlives the strand.awaitcallbacks and timer callbacks run inside the strand.co_await.context::current()
schedule_awaiterand the spawn final awaiter decide with it. Before, they usedowns_thread(), which is also true inside a strand job of the same scheduler, so a coroutine could not leave a strand and a spawn caller could end up inside one.Shared asio code exists once:
src/utility/asio/ops.hpp(post_on,await_on), the macro inasio/macro.hpp.Tests: 1000 jobs on 4 workers run one at a time and in order, awaits run inside the strand,
executor{strand}.schedule(), a coroutine leaves a strand, spawn from and into a strand,current(), a scheduler job runs while a strand job runs. 297/297 on gcc and clang, debug and release. ASan: 0 leaks.