Sync::Mutex
Inherits Sync::Lockable / Reference / Object
A mutual exclusion lock to protect critical sections.
A single fiber can acquire the lock at a time. No other fiber can acquire the lock while a fiber holds it.
This lock can for example be used to protect the access to some resources, with the guarantee that only one section of code can ever read, write or mutate said resources.
NOTE: Consider Exclusive(T) to protect a value T with a Mutex.
Constructors
new(type : Type = :checked)
SourceInstance methods
synchronize
Acquires the exclusive lock for the duration of the block. The lock will be released automatically before returning, or if the block raises an exception.