immutable locked class Mutex
Class Mutex
is an implementation of Mutual-Exclusion in Shadow. This implementation allows nested locks, which can be useful in some scenarios, such as with recursive methods.
Claude Abounegm
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
create() Initializes a new |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
destroy() |
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly |
(Mutex) |
copy(AddressMap addresses) |
public readonly locked |
() |
free() Frees the resources allocated by this |
public readonly locked |
() |
lock() Attempts to lock this mutex. |
public readonly locked |
() |
unlock() Attempts to unlock this mutex. |
public create() => ()
Initializes a new Mutex
.
public destroy() => ()
public readonly copy(AddressMap addresses) => (Mutex)
public readonly locked free() => ()
Frees the resources allocated by this Mutex
.
MutexException
- if the Mutex is locked by another thread.
public readonly locked lock() => ()
Attempts to lock this mutex. If the mutex is already owned by another thread, this method blocks until the mutex becomes available. If the current thread already owns this mutex, this method will simply increase the counter. The mutex should be unlocked the same number of times it was locked.
FreedResourceException
- if the mutex has been freed.
public readonly locked unlock() => ()
Attempts to unlock this mutex. If the mutex has been locked multiple times by this thread, this method simply decreases the counter. This mutex is unlocked when an corresponding unlock has been called for each lock. i.e. If lock()
was called twice, unlock()
will unlock the mutex on its second call.
MutexException
- if this mutex is not owned by this thread.
FreedResourceException
- if the mutex has been freed.