Cyber Garage Portable Runtime (CGPR) for C
thread.c File Reference
#include <signal.h>
#include <cgpr/util/thread.h>
#include <cgpr/util/time.h>
#include <string.h>

Functions

static void cg_sig_handler (int sign)
 
static void * cg_posix_thread_proc (void *param)
 
CGThreadcg_thread_new (void)
 
bool cg_thread_delete (CGThread *thread)
 
bool cg_thread_start (CGThread *thread)
 
bool cg_thread_stop (CGThread *thread)
 
bool cg_thread_restart (CGThread *thread)
 
bool cg_thread_isrunnable (CGThread *thread)
 
bool cg_thread_isrunning (CGThread *thread)
 
void cg_thread_setaction (CGThread *thread, CG_THREAD_FUNC func)
 
void cg_thread_setuserdata (CGThread *thread, void *value)
 
void * cg_thread_getuserdata (CGThread *thread)
 

Function Documentation

◆ cg_posix_thread_proc()

static void * cg_posix_thread_proc ( void * param)
static

◆ cg_sig_handler()

static void cg_sig_handler ( int sign)
static

◆ cg_thread_delete()

bool cg_thread_delete ( CGThread * thread)

Stop and destroy a thread.

Parameters
threadThread to destroy

◆ cg_thread_getuserdata()

void * cg_thread_getuserdata ( CGThread * thread)

Get the user data pointer

Parameters
threadThread from which to get the pointer

◆ cg_thread_isrunnable()

bool cg_thread_isrunnable ( CGThread * thread)

Check if a thread has been started

Parameters
threadThread to check

◆ cg_thread_isrunning()

bool cg_thread_isrunning ( CGThread * thread)

◆ cg_thread_new()

CGThread * cg_thread_new ( void )

Create a new thread

◆ cg_thread_restart()

bool cg_thread_restart ( CGThread * thread)

Restart a thread. Essentially calls cg_thread_stop() and cg_thread_start()

Parameters
threadThread to restart

◆ cg_thread_setaction()

void cg_thread_setaction ( CGThread * thread,
CG_THREAD_FUNC actionFunc )

Set the thread's worker function.

Parameters
threadThread struct
actionFuncFunction pointer to set as the worker function

◆ cg_thread_setuserdata()

void cg_thread_setuserdata ( CGThread * thread,
void * data )

Set the user data pointer

Parameters
threadThread struct
dataPointer to user data

◆ cg_thread_start()

bool cg_thread_start ( CGThread * thread)

Start a thread (must be created first with ch_thread_new())

Parameters
threadThread to start

◆ cg_thread_stop()

bool cg_thread_stop ( CGThread * thread)

Stop a running thread.

Parameters
threadThread to stop