robur-coop / miou

A simple scheduler for OCaml 5
https://docs.osau.re/miou/index.html
MIT License
93 stars 7 forks source link

Behavior of `Miou.call` #1

Closed dinosaure closed 1 year ago

dinosaure commented 1 year ago

Currently, if a domain has some suspended tasks, it does not take the opportunity to take a new task. That's mostly means that when a domain took a task which has some blockers, it will be busy on this specific task until the termination. In the case of a "daemon" task, a domain will be busy with only one even if the daemon does nothing.

It can be interesting to let an opportunity of a domains to take a task even if it has some suspended tasks. See (glist is pending tasks, clist is tasks to cancel and blist is blockers): https://github.com/roburio/miou/blob/0ca25ddb410a26155d77df8ee3780d34302f7d92/lib/miou.ml#L504-L507

However, certain patterns require that some tasks was really in parallel: two subsequent uses of Miou.call don't assert that 2 domains will be used. So we probably need to provide something where we assert that 2 tasks will be run in parallel in anyway. For in instance, we should have:

let prms = Miou.in_parallel [ p0; p1 ] in
Miou.await_all prms

Such case exists in our test (basics/t03.exe) where we must launch tasks in parallel - otherwise, we will get a dead-lock.

dinosaure commented 1 year ago

The proposed change was fixed by 9b05e4348abd8c1d72893ba9e50cd7f2eb48cf46.