struct

Syn::Core::WaitGroup

Inherits Struct / Value / Object

Suspend execution until other fibers are finished.

Constructors

new(counter : Int32 = 0)
Source

Instance methods

add(count : Int) : Nil

Increments the counter by how many fibers we want to wait for.

Can be called at any time, allowing concurrent fibers to add more fibers to wait for, but they must always do so before calling #done to decrement the counter, to make sure that the counter may never inadvertently reach zero before all fibers are done.

Source
done

Decrements the counter by one. Must be called by concurrent fibers once they have finished processing. When the counter reaches zero, all waiting fibers will be resumed.

Source
wait(timeout : Time::Span) : Bool

Same as #wait but only waits until timeout is reached. Returns true if the counter reached zero; returns false if timeout was reached.

Source
wait

Suspends the current fiber until the counter reaches zero, at which point the fiber will be closed.

Can be called from different fibers.

Source