Skip to content

Commit

Permalink
Update concurrency_summary.md
Browse files Browse the repository at this point in the history
  • Loading branch information
durandaltheta committed May 21, 2024
1 parent eb5338b commit 039d106
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions concurrency_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ The operating theory of this algorithm is that if rebalancing occurs only when i

---
### custom scheduling
The user can implement their own scheduling algorithm on a `mce::threadpool` by calling `mce::threadpool::workers()` which returns a `std::vector<std::shared_ptr<mce::scheduler>>` of schedulers running on worker threads managed by the `mce::threadpool`. The user can then choose when and how to call `mce::scheduler::schedule()` to launch new coroutines.
The user can implement their own scheduling algorithm on a `mce::threadpool` by calling `mce::threadpool::workers()` which returns a `std::vector<std::shared_ptr<mce::scheduler>>` of schedulers running on worker threads managed by the `mce::threadpool` or by calling `mce::scheduler& mce::threadpool::worker(size_t)` with a specific index to retrieve a given worker's scheduler. The user can then choose when and how to call `mce::scheduler::schedule()` to launch new coroutines.

A *potential* usecase for this is to guarantee that certain high level, root operations execute on different threads, such as launching various services during program startup. The scheduling algorithms generally attempt their best to accomplish this (even `mce::concurrent()` attempts to accomplish this, because it falls back to the background `mce::default_threadpool()` when not called on a running `mce::scheduler`, which is generally the case in a program `main()`). However, the scheduling algorithms do not have any way to distinguish between tasks passed to them, and may sometimes require user intervention to handle edgecases.
A *potential* usecase for this is to guarantee that certain high level, root operations execute on different threads, such as launching various services during program startup. The scheduling algorithm `ccc::parallel()` generally attempts to accomplish this. However, `ccc::parallel()` do not have any way to distinguish between tasks passed to it, and may sometimes require user intervention to handle edgecases.

For instance, if a program's `main()` is launching distinct services at startup which need to be evenly distributed across threads, and those services *themselves* schedule on their associated `mce::threadpool()` (the `mce::default_threadpool()`), the `mce::threadpool()` may accidentally schedule two root services on the same thread because `main()` is in competition with a running coroutine for access to `mce::threadpool::schedule()`.

Expand Down

0 comments on commit 039d106

Please sign in to comment.