1-- The blocking provider's `fibre.scheduler` (D444): it runs
2-- each task to its end, on the caller's stack, before `start` returns,
3-- as `fibre.whole` does. Its calls block the thread, so it has nothing
4-- to yield to and is no provider of `fibre.turns`; a program that needs
5-- turns makes a round, or mints hosted/events, instead. It
6-- imports core/fibre and not its switch, so every hosted target admits
7-- it whether or not its backend switches stacks.
8
9import core/fibre
10import core/mem
11
12scheduler_start: (self: host, escaping record: ptr mut fibre.space,
13 escaping stack: []mut u8, escaping work: any fibre.task)
14 -> none ! mem.out_of_memory =
15 _ = self
16 _ = stack
17 record.val.status = 1
18 work.run()
19 record.val.status = 0
20end scheduler_start
21
22scheduler_finished: (self: host, record: fibre.space) -> (yes: bool) =
23 _ = self
24 yes = record.status == 0
25end scheduler_finished
26
27-- Nothing is ever running when `start` has returned.
28scheduler_wait: (self: host) -> none =
29 _ = self
30end scheduler_wait
31
32host is fibre.scheduler (start: scheduler_start, finished: scheduler_finished,
33 wait: scheduler_wait)