Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

lfc::posixPAL::threads Namespace Reference

posix threads PAL. More...


Compounds

struct  lfc::posixPAL::threads::__StartThreadInfo
 used to pass __threadProc needed information. More...

struct  lfc::posixPAL::threads::ThreadHandle
 posix thread handle type. More...

struct  lfc::posixPAL::threads::MutexHandle
 posix mutex handle type. More...

struct  lfc::posixPAL::threads::SemHandle
 posix semaphore handle type. More...


Typedefs

typedef ::pthread_key_t TLSKey
 posix TLS key type. More...


Enumerations

enum  ErrorCodes { errOk, errGeneric }

Functions

void * __threadProc (void *)
 tool for using posix threads. More...

int init ()
 init threads PAL. More...

int cleanup ()
 cleanup threads PAL. More...

int createThread (ThreadHandle &handle, void(*proc)(void *), void *pData)
 create a new thread. More...

int closeThread (ThreadHandle &handle)
 close a thread handle. More...

int getCurrentThread (ThreadHandle &handle)
 get current thread handle. More...

int destroyThread (const ThreadHandle &handle)
 destroy a thread (terminate async). More...

int joinThread (const ThreadHandle &handle)
 wait for a thread to terminate. More...

int setThreadPriority (const ThreadHandle &handle, int priority)
 set thread priority. More...

int yield ()
 yield. More...

int sleep (long miliseconds)
 suspends execution for a specified interval. More...

int allocTLS (TLSKey &key)
 alloc new TLS. More...

int freeTLS (TLSKey key)
 free TLS. More...

int setTLS (TLSKey key, void *value)
 set TLS. More...

int getTLS (TLSKey key, void *&value)
 get TLS. More...

int createMutex (MutexHandle &handle)
 create a new mutex object. More...

int closeMutex (MutexHandle &handle)
 close a mutex. More...

int lockMutex (MutexHandle &handle)
 lock a mutex. More...

int tryLockMutex (MutexHandle &handle, bool &bLocked)
 try to lock a mutex w/o blocking. More...

int unlockMutex (MutexHandle &handle)
 unlock a mutex. More...

int createSemaphore (SemHandle &handle, long count)
 create a new semaphore object. More...

int closeSemaphore (SemHandle &handle)
 close a semaphore. More...

int waitSemaphore (SemHandle &handle)
 wait a semaphore (lock). More...

int tryWaitSemaphore (SemHandle &handle, bool &bLocked)
 wait a semaphore w/o blocking (lock). More...

int postSemaphore (SemHandle &handle)
 post a semaphore (unlock). More...

const char * message (int index)
 return the message coresponding to a return code. More...


Variables

const int MAX_ERROR_CODE = 1
const char * messagesTable [MAX_ERROR_CODE+1]
const ThreadHandle NULL_THREAD_HANDLE = ThreadHandle()
 a handle value designating an invalid thread handle. More...

const MutexHandle NULL_MUTEX_HANDLE = MutexHandle()
 a handle value designating an invalid mutex handle. More...

const SemHandle NULL_SEM_HANDLE = SemHandle()
 a handle value designating an invalid semaphore handle. More...

const int priorityMin = -1
 thread priority. More...

const int priorityNormal = 0
 thread priority. More...

const int priorityMax = 1
 thread priority. More...


Detailed Description

posix threads PAL.

Todo:
needs testing

more detailed return codes


Typedef Documentation

typedef ::pthread_key_t lfc::posixPAL::threads::TLSKey
 

posix TLS key type.


Enumeration Type Documentation

enum lfc::posixPAL::threads::ErrorCodes
 

Enumeration values:
errOk 
errGeneric 


Function Documentation

void * lfc::posixPAL::threads::__threadProc void *    p
 

tool for using posix threads.

Note:
new/delete must be thread safe

int init   [inline]
 

init threads PAL.

Returns:
error code (0 means no error)

int cleanup   [inline]
 

cleanup threads PAL.

Returns:
error code (0 means no error)

int createThread ThreadHandle   handle,
void(*    proc)(void *),
void *    pData
[inline]
 

create a new thread.

Parameters:
handle  will contain the handle if the operation succed, no modification otherwhise
proc  address of thread starting function
pData  application defined value (passed to proc)
Returns:
error code (0 means no error)

int closeThread ThreadHandle   handle [inline]
 

close a thread handle.

Parameters:
handle  thread handle
Returns:
error code (0 means no error)

int getCurrentThread ThreadHandle   handle [inline]
 

get current thread handle.

Parameters:
handle  will contain the handle if the operation succed, no modification otherwhise
Returns:
error code (0 means no error)
Note:
the handle returned is not a pseudohandle, and must be closed when no longer used. There is no guarantee that this handle is the same with that returned when thread was created.

int destroyThread const ThreadHandle   handle [inline]
 

destroy a thread (terminate async).

Parameters:
handle  thread handle
Returns:
error code (0 means no error)

int joinThread const ThreadHandle   handle [inline]
 

wait for a thread to terminate.

Parameters:
handle  thread handle
Returns:
error code (0 means no error)

int setThreadPriority const ThreadHandle   handle,
int    priority
[inline]
 

set thread priority.

Parameters:
handle  thread handle
priority  new thread priority
Returns:
error code (0 means no error)

int yield   [inline]
 

yield.

Returns:
error code (0 means no error)

int sleep long    miliseconds [inline]
 

suspends execution for a specified interval.

Parameters:
miliseconds  the interval duration
Returns:
error code (0 means no error)

int allocTLS TLSKey   key [inline]
 

alloc new TLS.

Parameters:
key  will contain the new key
Returns:
error code (0 means no error)

int freeTLS TLSKey    key [inline]
 

free TLS.

Parameters:
key  TLS key
Returns:
error code (0 means no error)
Note:
TLS are freed at the process termination

int setTLS TLSKey    key,
void *    value
[inline]
 

set TLS.

Parameters:
key  TLS key
value  the value
Returns:
error code (0 means no error)

int getTLS TLSKey    key,
void *&    value
[inline]
 

get TLS.

Parameters:
key  TLS key
value  will contain the value
Returns:
error code (0 means no error)

int lfc::posixPAL::threads::createMutex MutexHandle   handle [inline]
 

create a new mutex object.

Parameters:
handle  will contain the handle if the operation succed, no modification otherwhise
Returns:
error code (0 means no error)

int closeMutex MutexHandle   handle [inline]
 

close a mutex.

Parameters:
handle  indicate mutex to be closed
Returns:
error code (0 means no error)

int lockMutex MutexHandle   handle [inline]
 

lock a mutex.

Parameters:
handle  indicate mutex
Returns:
error code (0 means no error)
Note:
recursive locks ok

int tryLockMutex MutexHandle   handle,
bool &    bLocked
[inline]
 

try to lock a mutex w/o blocking.

Parameters:
handle  indicate mutex
bLocked  return true if lock succeded
Returns:
error code (0 means no error)
Note:
recursive locks ok

int unlockMutex MutexHandle   handle [inline]
 

unlock a mutex.

Parameters:
handle  indicate mutex
Returns:
error code (0 means no error)

int createSemaphore SemHandle   handle,
long    count
[inline]
 

create a new semaphore object.

Parameters:
handle  will contain the handle if the operation succed, no modification otherwhise
count  initial semaphore value
Returns:
error code (0 means no error)

int closeSemaphore SemHandle   handle [inline]
 

close a semaphore.

Parameters:
handle  indicate semaphore to be closed
Returns:
error code (0 means no error)

int waitSemaphore SemHandle   handle [inline]
 

wait a semaphore (lock).

Parameters:
handle  indicate semaphore
Returns:
error code (0 means no error)

int tryWaitSemaphore SemHandle   handle,
bool &    bLocked
[inline]
 

wait a semaphore w/o blocking (lock).

Parameters:
handle  indicate semaphore
bLocked  return true if lock succeded
Returns:
error code (0 means no error)

int postSemaphore SemHandle   handle [inline]
 

post a semaphore (unlock).

Parameters:
handle  indicate semaphore
Returns:
error code (0 means no error)

const char* message int    index [inline]
 

return the message coresponding to a return code.

Parameters:
index  message index (return code from other pal functions)


Variable Documentation

const int lfc::posixPAL::threads::MAX_ERROR_CODE = 1
 

const char * lfc::posixPAL::threads::messagesTable
 

Initial value:

{
    "posixPAL::threads -- No error (ok)",
    "posixPAL::threads -- Generic error",
}

const ThreadHandle lfc::posixPAL::threads::NULL_THREAD_HANDLE = ThreadHandle()
 

a handle value designating an invalid thread handle.

const MutexHandle lfc::posixPAL::threads::NULL_MUTEX_HANDLE = MutexHandle()
 

a handle value designating an invalid mutex handle.

const SemHandle lfc::posixPAL::threads::NULL_SEM_HANDLE = SemHandle()
 

a handle value designating an invalid semaphore handle.

const int lfc::posixPAL::threads::priorityMin = -1
 

thread priority.

const int lfc::posixPAL::threads::priorityNormal = 0
 

thread priority.

const int lfc::posixPAL::threads::priorityMax = 1
 

thread priority.


Generated on Sat Jan 26 00:35:12 2002 for LFC2 PAL by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001