Module
Threading.Data.Mutex
- Package
- purescript-threading
- Repository
- cakekindel/purescript-threading
A Mutex allows any number of threads to share mutable state, with at most 1 thread having read or write access at a time.
Threads can access the data with lock
or tryLock
,
which both return a Guard
.
The holder of a Guard
is guaranteed exclusive read &
write access to the data contained in the Mutex
.
#Guard Source
data Guard t0
A lock to a Mutex.
Guards may be read from, written to, and released. Guards must be released in order for other blocking threads to continue.
Note: If a Guard reclaimed by the garbage collector without being released, its Mutex will notice and behave as if the Guard was explicitly released. This will hopefully catch deadlocks caused by threads that have exited while holding a Guard.