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
Any Condition

Constructors

new()
#

Methods

Wait(Mutex mutex)
#
Wait(Mutex mutex, i32 milliseconds) : bool
#

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()
#

override

Private and internal members (6)

i64 handle
#

private

static extern("cond.new") New() : i64
#

private static

static extern("cond.wait") WaitNative(i64 condition, i64 mutex, i64 milliseconds) : i64
#

private static

static extern("cond.signal") SignalNative(i64 condition)
#

private static

static extern("cond.broadcast") BroadcastNative(i64 condition)
#

private static

static extern("cond.free") Free(i64 condition)
#

private static

Inherited members (4)

Source

Condition as Antril, decompiled from its Larva HIR.

System.Threading.Condition.ant
// 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();
				}
			}
	}
}
Esc