Event.unreliableWait

waits for the event to be set with potential spurious wakeups

If the event is already set, returns without sleeping.

The main difference between this method and wait is that this method supports the case where the struct holding the Event is freed while the fiber is sleeping. As a result, two main differences are possible:

  1. Spurious wakeups are possible (i.e. - unreliableWait returns, but the event is not set)
  2. The VerboseEvent will not report when we wake up from the sleep.

Proper invocation should use the following pattern:

while( isEventValid && !event.unreliableWait ) {}

It should be pointed out that spurious wakeups only happen when another fiber sets the event. This might still be a spurious because another fiber might reset the event before the waiting fiber gets a chance to run. If this is a desired behavior, you might wish to check whether Signal fits your needs better.

struct Event
@safe @nogc
bool
unreliableWait

Parameters

timeout Timeout

sets a timeout for the wait.

Return Value

Type: bool

Returns true if the event was already set when the call was made.

Throws

TimeoutExpired if the timeout expires.

Any other exception injected to this fiber using Reactor.throwInFiber

Meta