Skip to content
CShift0.32

MutexGuard<T>

Struct · namespace System · Since 0.04

struct MutexGuard<T> : IDisposable

Holds the lock of a Mutex<T> until Dispose(). Copies of a guard share the “held” flag, so the lock is released once. A guard cannot be passed to another thread (the thread that locked a mutex has to unlock it).

Name Description
Get A copy of the guarded value.
Set Replaces the guarded value.
Dispose Releases the lock (once; disposing a guard again does nothing).
T Get()

A copy of the guarded value.

Panics when the guard was disposed already.

void Set(T value)

Replaces the guarded value.

Panics when the guard was disposed already.

void Dispose()

Releases the lock (once; disposing a guard again does nothing).