Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Structs Mutex

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module 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;
    
}

Documentation

A basic, thread-safe mutex that's properly integrated with Juptune's event loop.

Notes

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.

Aliases

Name Description
__xdtor
__xpostblit

Constants

Name Description
LOCKED
LOCKED_WITH_WAITERS
TEARDOWN
UNLOCKED

Functions

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).