cthread.h File Reference

#include <cybergarage/typedef.h>
#include <cybergarage/util/clist.h>
#include <cybergarage/util/ccond.h>
#include <pthread.h>
#include <signal.h>

Data Structures

struct  _CgThread
 The generic wrapper struct for CyberLinkC's threads. More...

Defines

#define cg_thread_next(thread)   (CgThread *)cg_list_next((CgList *)thread)
#define cg_thread_remove(thread)   cg_list_remove((CgList *)thread)
#define cg_threadlist_clear(threadList)   cg_list_clear((CgList *)threadList, (CG_LIST_DESTRUCTORFUNC)cg_thread_delete)
#define cg_threadlist_size(threadList)   cg_list_size((CgList *)threadList)
#define cg_threadlist_gets(threadList)   (CgThread *)cg_list_next((CgList *)threadList)
#define cg_threadlist_add(threadList, thread)   cg_list_add((CgList *)threadList, (CgList *)thread)

Typedefs

typedef _CgThread CgThread
 The generic wrapper struct for CyberLinkC's threads.
typedef _CgThread CgThreadList
 The generic wrapper struct for CyberLinkC's threads.
typedef void(*) CG_THREAD_FUNC (CgThread *)

Functions

CgThreadcg_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 actionFunc)
void cg_thread_setuserdata (CgThread *thread, void *data)
void * cg_thread_getuserdata (CgThread *thread)
CgThreadListcg_threadlist_new ()
void cg_threadlist_delete (CgThreadList *threadList)
BOOL cg_threadlist_start (CgThreadList *threadList)
BOOL cg_threadlist_stop (CgThreadList *threadList)

Define Documentation

#define cg_thread_next ( thread   )     (CgThread *)cg_list_next((CgList *)thread)

#define cg_thread_remove ( thread   )     cg_list_remove((CgList *)thread)

#define cg_threadlist_add ( threadList,
thread   )     cg_list_add((CgList *)threadList, (CgList *)thread)

Add a thread into a thread list

Parameters:
threadList The thread list in question
thread The thread to add to the list

#define cg_threadlist_clear ( threadList   )     cg_list_clear((CgList *)threadList, (CG_LIST_DESTRUCTORFUNC)cg_thread_delete)

Clear the contents of a thread list

Parameters:
threadList Thread list in question

#define cg_threadlist_gets ( threadList   )     (CgThread *)cg_list_next((CgList *)threadList)

Get the first actual item from a thread list to use as an iterator

Parameters:
threadList The thread list in question

#define cg_threadlist_size ( threadList   )     cg_list_size((CgList *)threadList)

Get the size of a thread list

Parameters:
threadList The thread list in question


Typedef Documentation

typedef void(*) CG_THREAD_FUNC(CgThread *)

Prototype for the threads' worker functions

typedef struct _CgThread CgThread

The generic wrapper struct for CyberLinkC's threads.

This wrapper has been created to enable 100% code compatibility between different platforms (Linux, Win32 etc..)

typedef struct _CgThread CgThreadList

The generic wrapper struct for CyberLinkC's threads.

This wrapper has been created to enable 100% code compatibility between different platforms (Linux, Win32 etc..)


Function Documentation

BOOL cg_thread_delete ( CgThread thread  ) 

Stop and destroy a thread.

Parameters:
thread Thread to destroy

void* cg_thread_getuserdata ( CgThread thread  ) 

Get the user data pointer

Parameters:
thread Thread from which to get the pointer

BOOL cg_thread_isrunnable ( CgThread thread  ) 

Check if a thread has been started

Parameters:
thread Thread 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:
thread Thread to restart

void cg_thread_setaction ( CgThread thread,
CG_THREAD_FUNC  actionFunc 
)

Set the thread's worker function.

Parameters:
thread Thread struct
actionFunc Function pointer to set as the worker function

void cg_thread_setuserdata ( CgThread thread,
void *  data 
)

Set the user data pointer

Parameters:
thread Thread struct
data Pointer to user data

BOOL cg_thread_start ( CgThread thread  ) 

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

Parameters:
thread Thread to start

BOOL cg_thread_stop ( CgThread thread  ) 

Stop a running thread.

Parameters:
thread Thread to stop

BOOL cg_thread_stop_with_cond ( CgThread thread,
CgCond cond 
)

Stop the running thread and signal the given CGCond.

void cg_threadlist_delete ( CgThreadList threadList  ) 

Destroy a thread list

Parameters:
threadList The thread list in question

CgThreadList* cg_threadlist_new (  ) 

Create a new thread list

Returns:
Thread list

BOOL cg_threadlist_start ( CgThreadList threadList  ) 

Start all threads in the thread list

Parameters:
threadList The thread list in question

BOOL cg_threadlist_stop ( CgThreadList threadList  ) 

Stop all threads in the thread list

Parameters:
threadList The thread list in question


Generated on Tue Aug 8 14:56:29 2006 for CyberLinkC by  doxygen 1.4.7