1234567891011121314151617181920212223242526272829303132module juptune.event.loop.mutex;
shared struct Mutex
{
/++ ALIASES ++/
///
alias __xdtor = __MARMOS_BUG__;
///
alias __xpostblit = __MARMOS_BUG__;
/++ FUNCTIONS ++/
/// Acquires the mutex's lock, yielding the current fiber until the lock has been acquired if needed.
Result lock();
///
Mutex opAssign(Mutex p);
/// Unlocks the mutex, regardless of whether the current fiber owns it or not (as exact ownership isn't tracked).
Result unlock();
/++ MANIFEST CONSTANTS ++/
///
enum int LOCKED = 1;
///
enum int LOCKED_WITH_WAITERS = 2;
///
enum int TEARDOWN = 10;
///
enum int UNLOCKED = 0;
}
A basic, thread-safe mutex that's properly integrated with Juptune's event loop.
When the mutex's dtor is called it will attempt to signal an error to all waiters in an attempt to prevent fibers from permanently sleeping.
If the mutex has any waiters, it is not safe to move it.
This is - unfortunately - not 100% reliable currently so please try not to rely on this failsafe functionality.
| Name | Description |
|---|---|
| __xdtor | |
| __xpostblit |
| Name | Description |
|---|---|
| LOCKED | |
| LOCKED_WITH_WAITERS | |
| TEARDOWN | |
| UNLOCKED |
| Name | Description |
|---|---|
| lock |
Acquires the mutex's lock, yielding the current fiber until the lock has been acquired if needed. |
| opAssign | |
| unlock |
Unlocks the mutex, regardless of whether the current fiber owns it or not (as exact ownership isn't tracked). |