struct Syn::Core::WaitGroup
- Syn::Core::WaitGroup
- Struct
- Value
- Object
Overview
Suspend execution until other fibers are finished.
Defined in:
core/wait_group.crConstructors
Instance Method Summary
-
#add(count : Int) : Nil
Increments the counter by how many fibers we want to wait for.
-
#done : Nil
Decrements the counter by one.
-
#wait(timeout : Time::Span) : Bool
Same as
#wait
but only waits untiltimeout
is reached.EXPERIMENTAL The timeout feature is experimental.
-
#wait : Nil
Suspends the current fiber until the counter reaches zero, at which point the fiber will be closed.
Constructor Detail
Instance Method Detail
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.
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.
Same as #wait
but only waits until timeout
is reached. Returns true
if the counter reached zero; returns false
if timeout was reached.
EXPERIMENTAL The timeout feature is experimental.
Suspends the current fiber until the counter reaches zero, at which point the fiber will be closed.
Can be called from different fibers.