c-template
wait_group.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdatomic.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include "../../include/sync/wait_group.h"
Include dependency graph for wait_group.c:

Go to the source code of this file.

Functions

wait_group_twait_group_new ()
 returns a new and initialized wait_group_t pointer More...
 
void wait_group_recv_signal (wait_group_t *wg)
 
void wait_group_send_signal (wait_group_t *wg)
 
void wait_group_reset_signal (wait_group_t *wg)
 
void wait_group_wait (wait_group_t *wg)
 used to wait until current active_processes reaches 0, polling every 0.75 seconds will run free on the wait_group_t pointer to clear up resources More...
 
void wait_group_add (wait_group_t *wg, int count)
 incremements the total number of active processes managed by this wait group More...
 
int wait_group_done (wait_group_t *wg)
 used by a process to indicate it is done, decreasing the active process counter we include a return code here to catch errors when trying to decrement count below 0 More...
 

Function Documentation

◆ wait_group_add()

void wait_group_add ( wait_group_t wg,
int  count 
)

incremements the total number of active processes managed by this wait group

Parameters
wgthe waitgroup to manipulate
countthe number of new active processes

Definition at line 64 of file wait_group.c.

Here is the caller graph for this function:

◆ wait_group_done()

int wait_group_done ( wait_group_t wg)

used by a process to indicate it is done, decreasing the active process counter we include a return code here to catch errors when trying to decrement count below 0

Precondition
wg->active_process must be greater than or equal to 1 otherwise return -1
Warning
in the future this may be changed so that calling wait_group_done with a 0 value active_processes will cause a program exit
Parameters
wgthe waitgroup to manipulate a runtime error will occur and program will exit
Returns
Failure: -1
Success: 0
Todo:
:
  • (bonedaddy) decide if we should do a runtime exit on pre condition failure

Definition at line 70 of file wait_group.c.

Here is the caller graph for this function:

◆ wait_group_new()

wait_group_t* wait_group_new ( )

returns a new and initialized wait_group_t pointer

Definition at line 9 of file wait_group.c.

Here is the caller graph for this function:

◆ wait_group_recv_signal()

void wait_group_recv_signal ( wait_group_t wg)

Definition at line 21 of file wait_group.c.

◆ wait_group_reset_signal()

void wait_group_reset_signal ( wait_group_t wg)

Definition at line 33 of file wait_group.c.

◆ wait_group_send_signal()

void wait_group_send_signal ( wait_group_t wg)

Definition at line 27 of file wait_group.c.

◆ wait_group_wait()

void wait_group_wait ( wait_group_t wg)

used to wait until current active_processes reaches 0, polling every 0.75 seconds will run free on the wait_group_t pointer to clear up resources

Parameters
wgthe waitgroup to wait on

Definition at line 45 of file wait_group.c.

Here is the caller graph for this function: