final class · System.Threading
CountdownEvent
public final class CountdownEvent
Set once it has been signaled initialCount times: Wait waits for that.
- Kind
- final class
- Namespace
- System.Threading
- Assembly
- System.Core
- Access
- public, final
- Source file
Threading.ant
Inheritance
- Base classes
-
AnyCountdownEvent
Constructors
Properties
Methods
One signal: whether that made it zero.
AddCount()
#
One more signal to wait for.
Wait()
#
Dispose()
#
Frees what it holds (it must not be used after).
Private and internal members (2)
ManualResetEvent zero
#
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
CountdownEvent as Antril, decompiled from its Larva HIR.
// System.Threading.CountdownEvent — System.Core (decompiled from Larva HIR)
import System;
into namespace System.Threading
{
/// Set once it has been signaled `initialCount` times: Wait waits for that.
public final class CountdownEvent
{
AtomicI32 left;
ManualResetEvent zero;
public:
new(i32 initialCount)
{
left = new AtomicI32(initialCount);
zero = new ManualResetEvent(initialCount == 0);
}
/// One signal: whether that made it zero.
Signal() : bool
{
i32 now = left.Decrement();
if (now < 0)
throw new InvalidOperationError("CountdownEvent: signaled more times than its count");
if (now == 0)
{
zero.Set();
return true;
}
return false;
}
/// One more signal to wait for.
AddCount()
{
left.Increment();
}
Wait()
{
zero.WaitOne();
}
Wait(i32 milliseconds) : bool => zero.WaitOne(milliseconds);
/// Frees what it holds (it must not be used after).
Dispose()
{
zero.Dispose();
}
i32 CurrentCount
{
get => left.Load();
}
bool IsSet
{
get => left.Load() == 0;
}
}
}