A module with support for things that are enrollable (barriers and broadcast channels).
- data Enrolled b a
- class Enrollable b z where
- enrollPair :: (Enrollable b p, Enrollable b' p') => (b p, b' p') -> ((Enrolled b p, Enrolled b' p') -> CHP a) -> CHP a
- enrollList :: Enrollable b p => [b p] -> ([Enrolled b p] -> CHP a) -> CHP a
An enrolled wrapper for barriers that shows at the type-level whether you are enrolled on a barrier. Enrolled Barriers should never be passed to two (or more) processes running in parallel; if two processes synchronise based on a single enroll call, undefined behaviour will result.
Enrolls on the given barrier, then executes the given function (passing it in the enrolled barrier) and when that function body finishes, resigns from the barrier and returns the result. If a poison or IO exception is thrown in the inside block, the barrier will be correctly resigned from, and the exception rethrown.
Do not attempt to return the enrolled barrier out of the inner function and use it afterwards.
Resigns from a barrier, then executes the given action, and when the
action finishes, re-enrolls on the barrier and continues. This function
is designed for use from inside the body of the
enroll function, to
temporarily resign from a barrier, do some things, then re-enroll. Do
not use the enrolled barrier inside the resign block. However, you may
enroll on the barrier inside this, nesting enroll and resign blocks as
much as you like
enroll but enrolls on the given pair of barriers