c-template
|
provides C equivalent of Golang sync.Wait enables "signalling" multiple threads allows management of multiple threads, and enabling clean exits or cleanups it is a bit different than joining pthreads to wait for processes to exit as it doesn't require attached pthreads (can be used with detached) for synchronizatiion More...
#include <stdio.h>
#include <pthread.h>
Go to the source code of this file.
Data Structures | |
struct | wait_group_t |
Typedefs | |
typedef struct wait_group_t | wait_group_t |
a simple structure of a pthread mutex and integer counter More... | |
Functions | |
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... | |
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... | |
wait_group_t * | wait_group_new () |
returns a new and initialized wait_group_t pointer More... | |
void | wait_group_recv_signal (wait_group_t *wg) |
void | wait_group_listen_signal (wait_group_t *wg) |
void | wait_group_send_signal (wait_group_t *wg) |
provides C equivalent of Golang sync.Wait enables "signalling" multiple threads allows management of multiple threads, and enabling clean exits or cleanups it is a bit different than joining pthreads to wait for processes to exit as it doesn't require attached pthreads (can be used with detached) for synchronizatiion
Definition in file wait_group.h.
a simple structure of a pthread mutex and integer counter
void wait_group_add | ( | wait_group_t * | wg, |
int | count | ||
) |
incremements the total number of active processes managed by this wait group
wg | the waitgroup to manipulate |
count | the number of new active processes |
Definition at line 64 of file wait_group.c.
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
wg | the waitgroup to manipulate a runtime error will occur and program will exit |
Definition at line 70 of file wait_group.c.
void wait_group_listen_signal | ( | wait_group_t * | wg | ) |
wait_group_t* wait_group_new | ( | ) |
returns a new and initialized wait_group_t pointer
Definition at line 9 of file wait_group.c.
void wait_group_recv_signal | ( | wait_group_t * | wg | ) |
Definition at line 21 of file wait_group.c.
void wait_group_send_signal | ( | wait_group_t * | wg | ) |
Definition at line 27 of file wait_group.c.
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
wg | the waitgroup to wait on |
Definition at line 45 of file wait_group.c.