robur-coop / miou

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

Improve the `Miou_unix.Cond` API #5

Closed dinosaure closed 7 months ago

dinosaure commented 1 year ago

Currently, the Miou_unix.Cond API can be a bit complex for the usage. The real issue is spurious wakeups. The "predicate" is not necessary false when a Miou_unix.Cond.wait wakeups and the user must check the predicate generally into a mutex. The basic usage is to redo the Condition.wait if we got a spurious wakeup.

On the API, we can provide something which care about that (and Miou_unix.Cond.until does that). We can also provide something more basic (with a nice documentation to explain spurious wakeups) and let the user to deal with that. Actually, Miou_unix.Cond uses a pipe() to allow the communication inter-process. We must think about what we should provide depending on implementation details.

/cc @darrenldl

dinosaure commented 7 months ago

Since miou.0.1.0, Miou.Condition is provided which is better (it uses internal structure than file-descriptors). Considering as fixed.