Private countThe number of items in the group to wait for
Private promiseThe internal promise of the wait group
Private rejectThe reject function of the internal promise of the wait group
Private resolveThe resolve function of the internal promise of the wait group
Add adds delta, which may be negative, to the WaitGroup counter.
If the counter becomes zero or negative, all the wait() will be released.
For such cases a result value will be used similar to the done() function call.
The delta value to increase, or decrease the counter of the WaitGroup
Optional result: anyThe result the wait() may return in case the count become 0 or less than zero
Generated using TypeDoc
A WaitGroup waits for a collection of async functions to finish.
This module simulates the working of the
WaitGrouptype of thesyncpackage of the Go programming language.The module implements a WaitGroup class, that waits for a collection of asynchronous function to finish.
The main function, that uses the
WaitGroupinitializes its counter or, calls theadd()method to set the number of async functions to wait for. Then each of the async functions runs and callsdone()when finished. Thedone()function must be called as many times the counter was set to. At the same time,wait()can be used to block until all async functions have finished. Thedone()calls may have aresult: anyparameter. In this case the parameter of the lastdone()call will be the return value of thewait()function.If there is a problem, the
fail()call will break the execution, so thewait()will return immediately with the optionalresult: anyparameter that was given to thefail()call.