---
name: "thread.h"
section: "3cc"
platform: "linux"
package: "libcommoncpp2-dev"
version: "1.0.13-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/thread.h/3cc"
---

# thread.h(3cc)

Synchronization and threading services.

## NAME

thread.h - Synchronization and threading services.

## SYNOPSIS

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

### Compounds

class **AtomicCounter**\
 *The AtomicCounter class offers thread-safe manipulation of an integer counter. atomic counter operation.* 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.* class **Conditional**\
 *A conditional variable synchcronization object for one to one and one to many signal and control events between processes. conditional.* class **Event**\
 *The Event class implements a feature originally found in the WIN32 API; event notification.* **Thread** *synchornization on event notification.* class **FixedBuffer**\
 *A buffer class that holds a known capacity of fixed sized objects defined during creation. producer/consumer buffer for fixed size objects.* 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.* class **MutexCounter**\
 *The* **Mutex** *Counter is a counter variable which can safely be incremented or decremented by multiple threads.* **Thread** *protected integer counter.* 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.* 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.* class **Thread**\
 *Every thread of execution in an application is created by instantiating an object of a class derived from the Thread class. base class used to derive all threads of execution.* 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.* 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.* 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.*

### Defines

\#define **CCXX\_POSIX**\
 \#define **TIMEOUT\_INF**   ~((**timeout\_t**) 0)\
 \#define **ENTER\_CRITICAL**   enterMutex();\
 \#define **LEAVE\_CRITICAL**   leaveMutex();\
 \#define **ENTER\_DEFERRED**   setCancel(cancelDeferred);\
 \#define **LEAVE\_DEFERRED**   setCancel(cancelImmediate);\
 \#define **psleep**(x)   (sleep)(x)\

### Typedefs

typedef pthread\_t **cctid\_t**\
 typedef unsigned long **timeout\_t**\

### Functions

timespec \* **getTimeout** (struct timespec \*spec, **timeout\_t** timeout)\
 void **wait** (signo\_t signo)\

### Variables

CCXX\_CLASS\_EXPORT **Thread**\
 CCXX\_CLASS\_EXPORT **ThreadKey**\
 CCXX\_CLASS\_EXPORT **Event**\

## DETAILED DESCRIPTION

Synchronization and threading services.

## DEFINE DOCUMENTATION

### #define CCXX\_POSIX

### #define ENTER\_CRITICAL enterMutex();

### #define ENTER\_DEFERRED setCancel(cancelDeferred);

### #define LEAVE\_CRITICAL leaveMutex();

### #define LEAVE\_DEFERRED setCancel(cancelImmediate);

### #define psleep(x) (sleep)(x)

### #define TIMEOUT\_INF ~((timeout\_t) 0)

## TYPEDEF DOCUMENTATION

### typedef pthread\_t cctid\_t

### typedef unsigned long timeout\_t

## FUNCTION DOCUMENTATION

### struct timespec\* getTimeout (struct timespec \* spec, timeout\_t timeout)

### void wait (signo\_t signo)

## VARIABLE DOCUMENTATION

### class CCXX\_CLASS\_EXPORT Event

### class CCXX\_CLASS\_EXPORT Thread

### class CCXX\_CLASS\_EXPORT ThreadKey

## AUTHOR

Generated automatically by Doxygen for CommonC++ from the source code.
