final class · System.Threading
Condition
public final class Condition
Waiting until another thread says something changed: Wait releases the mutex (which the caller holds) while it waits and takes it back before it returns. Signal wakes one waiter, Broadcast all. Wake-ups can be spurious: wait in a loop that checks what is waited for.
- Kind
- final class
- Namespace
- System.Threading
- Assembly
- System.Core
- Access
- public, final
- Source file
Threading.ant
Inheritance
- Base classes
-
AnyCondition
Constructors
new()
#
Methods
Waits at most milliseconds: false when the time ran out.
Signal()
#
Broadcast()
#
Dispose()
#
Frees it (it must not be used after; an undisposed one is freed when the object dies).
override destroy()
#
Private and internal members (6)
Inherited members (4)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Any
Source
Condition as Antril, decompiled from its Larva HIR.
// System.Threading.Condition — System.Core (decompiled from Larva HIR)
into namespace System.Threading
{
/// Waiting until another thread says something changed: Wait releases the mutex (which the caller holds) while it
/// waits and takes it back before it returns. Signal wakes one waiter, Broadcast all. Wake-ups can be spurious: wait in
/// a loop that checks what is waited for.
public final class Condition
{
i64 handle;
static extern("cond.new") New() : i64;
static extern("cond.wait") WaitNative(i64 condition, i64 mutex, i64 milliseconds) : i64;
static extern("cond.signal") SignalNative(i64 condition);
static extern("cond.broadcast") BroadcastNative(i64 condition);
static extern("cond.free") Free(i64 condition);
public:
new()
{
handle = New();
}
Wait(Mutex mutex)
{
WaitNative(handle, mutex.Handle, -1);
}
/// Waits at most `milliseconds`: false when the time ran out.
Wait(Mutex mutex, i32 milliseconds) : bool => WaitNative(handle, mutex.Handle, milliseconds) != 0;
Signal()
{
SignalNative(handle);
}
Broadcast()
{
BroadcastNative(handle);
}
/// Frees it (it must not be used after; an undisposed one is freed when the object dies).
Dispose()
{
if (handle != 0)
Free(handle);
handle = 0;
}
override destroy()
{
try
{
Dispose();
}
finally
{
base.destroy();
}
}
}
}