Lines Matching refs:marl
1 # `marl::Scheduler`
5 - [`marl::Scheduler`](#marlscheduler)
10 - [`marl::Scheduler::Worker::run()`](#marlschedulerworkerrun)
11 - [`marl::Scheduler::Worker::runUntilIdle()`](#marlschedulerworkerrununtilidle)
12 - [`marl::Scheduler::Worker::suspend()`](#marlschedulerworkersuspend)
13 - [`marl::Scheduler::Worker::waitForWork()`](#marlschedulerworkerwaitforwork)
14 - [`marl::Scheduler::Worker::spinForWork()`](#marlschedulerworkerspinforwork)
19 The `marl::Scheduler` is the most complex part of marl and is responsible for executing tasks and k…
25 The scheduler must be bound to each thread that calls `marl::schedule()`, and unbound from all thre…
27 Binding is made using the `marl::Scheduler::bind()` and `marl::Scheduler::unbind()` methods.
31 1. It allows `marl::schedule()` and the various synchronization primitives to be called without req…
32 … thread. This is used by `marl::ConditionVariable::wait()` to suspend the current fiber and place …
40 …marl implements the `marl::OSFiber` class for each supported platform and ABI. Most of these imple…
42 `marl::Scheduler::Fiber` is the public fiber interface that is tightly coupled with the `marl::Sche…
44 Each `marl::Scheduler::Fiber` is permanently associated with a `marl::Scheduler::Worker`, and is gu…
48 A `marl::Task` is an alias to `std::function<void()>`, a function that takes no arguments, and retu…
50 Tasks are scheduled using `marl::schedule()`, and are typically implemented as a lambda:
53 marl::schedule([] {
58 While the `marl::Task` signature takes no parameters, it is common to capture variables as part of …
60 …marl synchronization primitives (with exception of `marl::ConditionVariable`) hold a shared pointe…
63 marl::WaitGroup wg(1);
64 marl::schedule([=] { // capture by value, not reference!
73 The scheduler holds a number of `marl::Scheduler::Worker`s. Each worker holds:
81 When a task is scheduled with a call to `marl::schedule()`, a worker is picked, and the task is pla…
83 - If the scheduler has no dedicated worker threads (`marl::Scheduler::getWorkerThreadCount() == 0`)…
86 ### `marl::Scheduler::Worker::run()`
91 - In this loop call [`marl::Scheduler::Worker::runUntilIdle()`](#marl::Scheduler::Worker::runUntilI…
93 ### `marl::Scheduler::Worker::runUntilIdle()`
114 ### `marl::Scheduler::Worker::suspend()`
118 …lled. `suspend()` begins by calling [`Scheduler::Worker::waitForWork()`](#marl::Scheduler::Worker:…
122 …ing tasks. This fiber is created to begin execution in [`marl::Scheduler::Worker::run()`](#marl::S…
128 ### `marl::Scheduler::Worker::waitForWork()`
145 ### `marl::Scheduler::Worker::spinForWork()`
163 - If the steal was unsuccessful, `std::this_thread::yield()` is called to prevent marl from starvin…
172 …n the STW and MTW is the behavior of the worker's entry point function - `marl::Scheduler::Worker:…
176 A single-threaded-worker (STW) is created for each thread that is bound with a call to `marl::Sched…
178 If the scheduler has no dedicated worker threads (`marl::Scheduler::getWorkerThreadCount() == 0`), …
180 …d executed. Instead, tasks are only executed whenever there's a call to [`marl::Scheduler::Worker:…
181 …on for STWs and MTWs, and the first call will create a fiber which calls `marl::Scheduler::Worker:…
183 `marl::Scheduler::Worker::run()` is implemented for STWs as a loop that calls `marl::Scheduler::Wor…
189 marl::Scheduler scheduler;
194 // Calling marl::schedule() enqueues the task on the STW, but does not
196 marl::Event done;
197 marl::schedule([=] {
202 // marl::Event::wait() (indirectly) calls marl::Scheduler::Worker::suspend().
203 // marl::Scheduler::Worker::suspend() creates and switches to a fiber which
204 // calls marl::Scheduler::Worker::run() to run all enqueued tasks. The fiber
213 Multi-Threaded-Workers are created when `marl::Scheduler::setWorkerThreadCount()` is called with a …
215 Each MTW is paired with a new `std::thread` that calls `marl::Scheduler::Worker::run()`.
217 `marl::Scheduler::Worker::run()` is implemented for MTWs as a loop that calls `marl::Scheduler::Wor…