class · System.Threading

Mutex

public class System.Threading.Mutex : System.Any

A lock: one thread at a time between Lock and Unlock (not re-entrant: a thread that holds it must not lock it again). Run(() => …) holds it around a function. Dispose frees its handle (an undisposed one is freed when the object dies).

Kind
class
Namespace
System.Threading
Assembly
System.Core
Access
public
Source file
Threading.ant

Inheritance

Base classes
Any Mutex
Derived types
Lock

Constructors

constructor Mutex()
#

Properties

property Handle: i64
#

read-only

The handle (for Condition).

Methods

method Lock() -> void
#
method Unlock() -> void
#
method TryLock() -> bool
#

Takes it when no other thread holds it: whether it did.

method WaitOne() -> void
#

WaitOne and ReleaseMutex: the same as Lock and Unlock.

method ReleaseMutex() -> void
#
method Run(body: func<> : void) -> void
#

Runs body holding the lock.

method Dispose() -> void
#

Frees it (it must not be used after).

method destroy() -> void
#

override

Private and internal members (6)

field handle: i64
#

private

static method New() -> i64
#

private static

static method LockNative(handle: i64) -> void
#

private static

static method TryNative(handle: i64) -> i64
#

private static

static method UnlockNative(handle: i64) -> void
#

private static

static method Free(handle: i64) -> void
#

private static

Inherited members (4)

Source

Mutex as Larva HIR, decompiled from its Larva HIR.

System.Threading.Mutex.hir
// A lock: one thread at a time between Lock and Unlock (not re-entrant: a thread that holds it must not lock it again).
// `Run(() => …)` holds it around a function. Dispose frees its handle (an undisposed one is freed when the object dies).
public class System.Threading.Mutex : System.Any
{
    field handle: i64
    static method New() -> i64
    static method LockNative(handle: i64) -> void
    static method TryNative(handle: i64) -> i64
    static method UnlockNative(handle: i64) -> void
    static method Free(handle: i64) -> void
    constructor Mutex()
    method Lock() -> void
    method Unlock() -> void
    // Takes it when no other thread holds it: whether it did.
    method TryLock() -> bool
    // WaitOne and ReleaseMutex: the same as Lock and Unlock.
    method WaitOne() -> void
    method ReleaseMutex() -> void
    // Runs `body` holding the lock.
    method Run(body: func<> : void) -> void
    // Frees it (it must not be used after).
    method Dispose() -> void
    method destroy() -> void
    // The handle (for Condition).
    property Handle: i64
}
Esc