Wait-group primitives for coordinating worker completion.
More...
Wait-group primitives for coordinating worker completion.
◆ sys_waitgroup_add()
Add to the wait group counter.
- Parameters
-
| wg | Pointer to the wait group |
| delta | Number to add to the counter |
- Returns
- true if successful, false on error
Increments the wait group counter by delta. This should be called before starting worker threads that the wait group should wait for. Implementations may reject negative deltas.
◆ sys_waitgroup_deinit()
Deinitialize a wait group.
- Parameters
-
| wg | Pointer to the wait group to deinitialize |
Releases all resources associated with the wait group and renders it unusable. The counter should be 0 and no threads should be waiting in sys_waitgroup_wait() when this function is called.
◆ sys_waitgroup_done()
Decrement the wait group counter.
- Parameters
-
| wg | Pointer to the wait group |
- Returns
- true if successful, false on error
Decrements the wait group counter by 1. This should be called when a worker finishes its work. If the counter reaches 0, all threads waiting in sys_waitgroup_wait() will be released.
◆ sys_waitgroup_init()
Initialize a new wait group.
- Returns
- Initialized wait group structure
Creates and initializes a new wait group for thread synchronization. The wait group counter starts at 0. The returned wait group is ready for use with sys_waitgroup_add(), sys_waitgroup_done(), and sys_waitgroup_wait(). Implementations that use a static pool may return NULL after SYS_WAITGROUP_CAPACITY wait groups have been allocated.
◆ sys_waitgroup_wait()
Wait for a wait group to complete.
- Parameters
-
| wg | Pointer to the wait group to wait on |
Blocks until the wait group counter reaches 0, then returns. The counter should reach 0 through sys_waitgroup_done() calls from worker threads. Safe to call from multiple threads on the same wait group; all of them are released once the counter reaches 0. Does not deinitialize the wait group - call sys_waitgroup_deinit() once all waiters have returned.