Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

thread.h File Reference

#include <cc++/config.h>
#include <cc++/exception.h>
#include <pthread.h>
#include <semaphore.h>
#include <time.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>

Go to the source code of this file.

Compounds

class  AtomicCounter
 The AtomicCounter class offers thread-safe manipulation of an integer counter. atomic counter operation. More...

class  Buffer
 The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be used to transfer objects between one or more producer and consumer threads. Producer/Consumer buffer for use between threads. More...

class  Conditional
 A conditional variable sychcronization object for one to one and one to many signal and control events between processes. conditional. More...

class  Event
 The Event class implements a feature originally found in the WIN32 API; event notification. Thread synchornization on event notification. More...

class  FixedBuffer
 A buffer class that holds a known capacity of fixed sized objects defined during creation. producer/consumer buffer for fixed size objects. More...

class  Mutex
 The Mutex class is used to protect a section of code so that at any given time only a single thread can perform the protected operation. Mutex lock for protected access. More...

class  MutexCounter
 The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads. Thread protected integer counter. More...

class  MutexLock
 The MutexLock class is used to protect a section of code so that at any given time only a single thread can perform the protected operation. Mutex automatic locker for protected access. More...

class  PosixThread
class  Semaphore
 A semaphore is generally used as a synchronization object between multiple threads or to protect a limited and finite resource such as a memory or thread pool. Semaphore counter for thread synchronization. More...

class  Thread
 Every thread of execution in an application is created by deriving a unique class from the Thread class and by implementing the Run method. base class used to derive all threads of execution. More...

class  ThreadKey
 This class allows the creation of a thread context unique "pointer" that can be set and retrieved and can be used to create thread specific data areas for implementing "thread safe" library routines. container for thread specific data storage. More...

class  ThreadLock
 The ThreadLock class impliments a thread rwlock for optimal reader performance on systems which have rwlock support, and reverts to a simple mutex for those that do not. Posix rwlock extension for protected access. More...

class  TimerPort
 Timer ports are used to provide synchronized timing events when managed under a "service thread" such as SocketService. synchronized millisecond timing for service threads. More...


Defines

#define __CCXX_POSIX
#define TIMEOUT_INF   ~((timeout_t) 0)
#define ENTER_CRITICAL   EnterMutex();
#define LEAVE_CRITICAL   LeaveMutex();
#define ENTER_DEFERRED   setCancel(THREAD_CANCEL_DEFERRED);
#define LEAVE_DEFERRED   setCancel(THREAD_CANCEL_IMMEDIATE);
#define psleep(x)   (sleep)(x)
#define sleep(x)   ccxx_sleep((x) * 1000)
#define yield()   ccxx_yield()

Typedefs

typedef pthread_t cctid_t
typedef unsigned long timeout_t
typedef enum throw_t throw_t
typedef enum thread_cancel_t thread_cancel_t
typedef enum thread_suspend_t thread_suspend_t
typedef int signo_t

Enumerations

enum  throw_t { THROW_NOTHING, THROW_OBJECT, THROW_EXCEPTION }
enum  thread_cancel_t {
  THREAD_CANCEL_INITIAL = 0, THREAD_CANCEL_DEFERRED = 1, THREAD_CANCEL_IMMEDIATE, THREAD_CANCEL_DISABLED,
  THREAD_CANCEL_DEFAULT
}
enum  thread_suspend_t { THREAD_SUSPEND_ENABLE, THREAD_SUSPEND_DISABLE }

Functions

void execHandler (Thread *th)
 CCXX_EXPORT (Thread *) getThread(void)
 CCXX_EXPORT (throw_t) getException(void)
 CCXX_EXPORT (void) setException(throw_t mode)
void suspend (Thread &th)
 Suspend the execution of the specified thread. More...

void resume (Thread &th)
 Resume execution of the specified thread. More...

void sigHandler (int signo)
void signal (PosixThread &th, int signo)
void * getKey (ThreadKey &tk)
void setKey (ThreadKey &tk, void *ptr)
void operator++ (Mutex &m)
void operator-- (Mutex &m)
void operator++ (Semaphore &s)
void operator-- (Semaphore &s)
void operator++ (Event &s)
void operator-- (Event &s)
void signal (Event &ev)
void wait (Event &ev)
void wait (Event &ev, timeout_t timer)
void reset (Event &ev)
void signal (Semaphore &sem)
void wait (Semaphore &sem)
int get (Buffer &b, void *o)
int put (Buffer &b, void *o)
int peek (Buffer &b, void *o)
timespec * gettimeout (struct timespec *spec, timeout_t timeout)
void wait (signo_t signo)
void pdetach (void)
 This function provides a simple and portable means to fork/detach a process into a daemon. This function provides a simple and portable means to fork/detach a process into a daemon. More...


Variables

CCXX_CLASS_EXPORT Event


Define Documentation

#define ENTER_CRITICAL   EnterMutex();
 

#define ENTER_DEFERRED   setCancel(THREAD_CANCEL_DEFERRED);
 

#define LEAVE_CRITICAL   LeaveMutex();
 

#define LEAVE_DEFERRED   setCancel(THREAD_CANCEL_IMMEDIATE);
 

#define TIMEOUT_INF   ~((timeout_t) 0)
 

#define __CCXX_POSIX
 

#define psleep x      (sleep)(x)
 

#define sleep x      ccxx_sleep((x) * 1000)
 

#define yield      ccxx_yield()
 


Typedef Documentation

typedef pthread_t cctid_t
 

typedef int signo_t
 

typedef enum thread_cancel_t thread_cancel_t
 

typedef enum thread_suspend_t thread_suspend_t
 

typedef enum throw_t throw_t
 

typedef unsigned long timeout_t
 


Enumeration Type Documentation

enum thread_cancel_t
 

Enumeration values:
THREAD_CANCEL_INITIAL  
THREAD_CANCEL_DEFERRED  
THREAD_CANCEL_IMMEDIATE  
THREAD_CANCEL_DISABLED  
THREAD_CANCEL_DEFAULT  

enum thread_suspend_t
 

Enumeration values:
THREAD_SUSPEND_ENABLE  
THREAD_SUSPEND_DISABLE  

enum throw_t
 

Enumeration values:
THROW_NOTHING  
THROW_OBJECT  
THROW_EXCEPTION  


Function Documentation

CCXX_EXPORT void  
 

CCXX_EXPORT throw_t  
 

CCXX_EXPORT Thread *  
 

void execHandler Thread *   th
 

int get Buffer &   b,
void *   o
[inline]
 

void* getKey ThreadKey &   tk [inline]
 

struct timespec* gettimeout struct timespec *   spec,
timeout_t   timeout
 

void operator++ Event &   s [inline]
 

void operator++ Semaphore &   s [inline]
 

void operator++ Mutex &   m [inline]
 

void operator-- Event &   s [inline]
 

void operator-- Semaphore &   s [inline]
 

void operator-- Mutex &   m [inline]
 

void pdetach void  
 

This function provides a simple and portable means to fork/detach a process into a daemon. This function provides a simple and portable means to fork/detach a process into a daemon.

Author:
David Sugar <dyfet@ostel.com>

int peek Buffer &   b,
void *   o
[inline]
 

int put Buffer &   b,
void *   o
[inline]
 

void reset Event &   ev [inline]
 

void resume Thread &   th [inline]
 

Resume execution of the specified thread.

Parameters:
th   specified thread.

void setKey ThreadKey &   tk,
void *   ptr
[inline]
 

void sigHandler int   signo
 

void signal Semaphore &   sem [inline]
 

void signal Event &   ev [inline]
 

void signal PosixThread &   th,
int   signo
[inline]
 

void suspend Thread &   th [inline]
 

Suspend the execution of the specified thread.

Parameters:
th   specified thread.

void wait signo_t   signo
 

void wait Semaphore &   sem [inline]
 

void wait Event &   ev,
timeout_t   timer
[inline]
 

void wait Event &   ev [inline]
 


Variable Documentation

class CCXX_CLASS_EXPORT Event
 


Generated at Tue Nov 20 12:34:33 2001 for CommonC++ by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001