gml_Thread.h

Go to the documentation of this file.
00001 /**
00002  * @file gml_Thread.h
00003  *
00004  *    Wrapper around APR's cross-platform threading API.
00005  *
00006  *  Copyright (c) 2004 CLIPS-IMAG
00007  *
00008  *  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00009  *  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  *
00011  *  Created in December, 2004 (JL).
00012  */
00013 #ifndef __GML_THREAD__
00014 #define __GML_THREAD__
00015 
00016 #include "gml/base/gml_Types.h"
00017 #include "gml/base/gml_Errors.h"
00018 
00019 /**
00020  * gml_TThreadId --
00021  *
00022  *   Opaque identifier fo a thread.
00023  */
00024 typedef struct gml_TThread_* gml_TThreadId;
00025 
00026 
00027 /**
00028  * gml_TThreadRoutine --
00029  *
00030  *   The type of "main" thread procedures.
00031  */
00032 typedef void (*gml_TThreadProc) (gml_TThreadId, void*);
00033 
00034 
00035 /**
00036  * gml_TThreadExitProc --
00037  *
00038  *   The type of thread termination handlers.
00039  */
00040 typedef void (*gml_TThreadExitProc) (void*);
00041 
00042 
00043 /**
00044  * gml_Thread_Create --
00045  *
00046  *   Spawn a thread that runs <threadProc>, which is passed the
00047  *   <clientData> argument. Return the identifier of the spawned thread in
00048  *   <idPtr>.
00049  */
00050 GML_EXTERN_C
00051 gml_TError gml_Thread_Create (gml_TThreadId* idPtr, gml_TThreadProc threadProc, void* clientData);
00052 
00053 /** Returned when thread creation fails */
00054 extern gml_TError gml_gThreadErrorCantCreate;
00055 
00056 
00057 /**
00058  * gml_GetCurrentThread --
00059  *
00060  *   Return the identifier of the calling thread.
00061  */
00062 GML_EXTERN_C
00063 gml_TThreadId gml_Thread_GetCurrent ();
00064 
00065 
00066 /**
00067  * gml_Thread_CreateExitHandler --
00068  *
00069  *   Make sure <proc> gets called with argument <clientData> when the current
00070  *   thread terminates.
00071  */
00072 GML_EXTERN_C
00073 void gml_Thread_CreateExitHandler (gml_TThreadExitProc proc, void* clientData);
00074 
00075 
00076 /**
00077  * gml_Thread_DeleteExitHandler --
00078  *
00079  *   Cancel a call to <gml_Thread_CreateExitHandler>.
00080  */
00081 GML_EXTERN_C
00082 void gml_Thread_DeleteExitHandler (gml_TThreadExitProc proc, void* clientData);
00083 
00084 
00085 /**
00086  * gml_Thread_Sleep --
00087  *
00088  *   Suspend execution in the calling thread for at least <milliseconds>.
00089  */
00090 GML_EXTERN_C
00091 void gml_Thread_Sleep (UInt32 milliseconds);
00092 
00093 #endif /* __GML_THREAD__ */
00094 
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.