CyberLink for C

cthread.c File Reference

#include <signal.h>
#include <cybergarage/util/cthread.h>
#include <cybergarage/util/ctime.h>
#include <cybergarage/util/clog.h>
#include <string.h>

Functions

static void sig_handler (int sign)
static void cg_thread_createkey ()
CgThread * cg_thread_self ()
static void * PosixThreadProc (void *param)
CgThread * cg_thread_new ()
BOOL cg_thread_delete (CgThread *thread)
BOOL cg_thread_start (CgThread *thread)
BOOL cg_thread_stop (CgThread *thread)
BOOL cg_thread_stop_with_cond (CgThread *thread, CgCond *cond)
BOOL cg_thread_restart (CgThread *thread)
BOOL cg_thread_isrunnable (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)

Variables

static pthread_key_t cg_thread_self_ref
static pthread_once_t cg_thread_mykeycreated = PTHREAD_ONCE_INIT

Function Documentation

static void cg_thread_createkey ( ) [static]
BOOL cg_thread_delete ( CgThread *  thread)

Stop and destroy a thread.

Parameters:
threadThread to destroy
void* cg_thread_getuserdata ( CgThread *  thread)

Get the user data pointer

Parameters:
threadThread from which to get the pointer
BOOL cg_thread_isrunnable ( CgThread *  thread)

Check if a thread has been started

Parameters:
threadThread to check
CgThread* cg_thread_new ( )

Create a new thread

BOOL cg_thread_restart ( CgThread *  thread)

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

Parameters:
threadThread to restart
CgThread* cg_thread_self ( )

Get a self reference to thread.

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
void cg_thread_setuserdata ( CgThread *  thread,
void *  data 
)

Set the user data pointer

Parameters:
threadThread struct
dataPointer to user data
BOOL cg_thread_start ( CgThread *  thread)

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

Parameters:
threadThread to start
BOOL cg_thread_stop ( CgThread *  thread)

Stop a running thread.

Parameters:
threadThread to stop
BOOL cg_thread_stop_with_cond ( CgThread *  thread,
CgCond *  cond 
)

Stop the running thread and signal the given CGCond.

static void* PosixThreadProc ( void *  param) [static]
static void sig_handler ( int  sign) [static]

Variable Documentation

pthread_once_t cg_thread_mykeycreated = PTHREAD_ONCE_INIT [static]
pthread_key_t cg_thread_self_ref [static]