cheshirekow  v0.1.0
pthreads Namespace Reference

Wraps posix-threads (pthreads.h) with object oriented API. More...

Classes

struct  Access
 access delegate, an object which can access an attribute value of an attribute object More...
 
struct  Assignment
 assignment delegate, an object which can assign an attribute value to an attribute object More...
 
class  Attr
 Attributes object for type Base. More...
 
struct  AttrType
 template used to resolve the pthreads_xxx_t object corresponding to the Attr<Base> object More...
 
struct  AttrType< Barrier >
 A simple way of telling Attr<Barrier> that it's storage type is pthread_barrierattr_t. More...
 
struct  AttrType< Condition >
 A simple way of telling Attr<Condition> that it's storage type is pthread_condattr_t. More...
 
struct  AttrType< Mutex >
 A simple way of telling Attr<Mutex> that it's storage type is pthread_mutexattr_t. More...
 
struct  AttrType< Thread >
 A simple way of telling Attr<Thread> that it's storage type is pthread_attr_t. More...
 
class  Barrier
 A barrier is an object which synchronizes a fixed number of threads at a specific point. More...
 
class  Condition
 Allows multiple threads to wait until a condition is satisfied. More...
 
struct  Delegate
 two-way delegate, may assign or retrieve (unsafely) an attribute value of an attribute object More...
 
struct  Friendly
 since a template parameter cannot be a friend (until C++-11) this template simply allows us to work around that limitation More...
 
class  Key
 A key is an identifier used to specify a storage location where the thing stored is different for each thread. More...
 
class  Mutex
 a mutual exclusion lock More...
 
class  ScopedLock
 Points to a locked mutex and unlocks the mutex when destroyed. More...
 
struct  Stack
 Simply encapsulates the stack address and size in a single object. More...
 
class  Thread
 A thread... presumably you know what this is. More...
 
struct  TypeWrap
 Provides a unique type that acts like a native type. More...
 

Typedefs

typedef TypeWrap< clockid_t, 0 > Clock
 A unique type which acts just like clockid_t but is distinct in the eyes of the compiler. More...
 
typedef TypeWrap< std::size_t, 0 > GuardSize
 A unique type which acts just like size_t but is distinct in the eyes of the compiler. More...
 
typedef TypeWrap< int, 0 > PriorityCeiling
 A unique type which acts just like an int but is distinct in the eyes of the compiler. More...
 
typedef TypeWrap< std::size_t, 1 > StackSize
 A unique type which acts just like size_t but is distinct in the eyes of the compiler. More...
 

Enumerations

enum  DetachState { DETACHED = 0, JOINABLE = 1, INVALID_DETACH_STATE }
 controls whether a thread is created in a detached state, meaning that the thread will destroy itself when it finished running, and cannot be joined More...
 
enum  InheritSched { INHERIT = 0, EXPLICIT = 1, INVALID_INHERIT_SCHED }
 determines whether a thread inherits it's scheduling policy from the creating thread or if it uses the policy stored in the attribute object More...
 
enum  Protocol { PRIO_NONE, PRIO_INHERIT, PRIO_PROTECT, INVALID_PROTOCOL }
 Which progocol is used for priority. More...
 
enum  PShared { SHARED, PRIVATE, INVALID_PSHARED }
 indicates whether or not a resource is shared across processes More...
 
enum  SchedPolicy {
  OTHER, FIFO, RR, BATCH,
  IDLE, SPORADIC, INVALID_SCHED_POLICY
}
 if multiple threads are waiting on the same mutex, the Scheduling Policy determines the order in which they are aquired More...
 
enum  Scope { SYSTEM = 0, PROCESS = 1, INVALID_SCOPE }
 Signifies process or system scheduling contention scope. More...
 
enum  Type {
  NORMAL, ERROR_CHECK, RECURSIVE, DEFAULT,
  INVALID_TYPE
}
 Types of mutexes. More...
 

Functions

template<class T >
void * callCallable (void *obj)
 function which invokes a callable object when that object is passed to launch a thread More...
 
template<typename Enum >
Enum getEnum (int val)
 returns the pthread integer enumerator that corresponds to the specified value More...
 
template<typename Enum >
int * getEnumMap ()
 returns pointer to a map from enums to pthread enums (ints) More...
 
template<typename Enum >
int mapEnum (Enum val)
 returns the pthread integer enumerator that corresponds to the specified value More...
 

Variables

const Access< Barrier, PSharedB_PSHARED
 provides access to the pshared field of a pthread_barrierattr_t More...
 
const Access< Condition, PSharedC_PSHARED
 provides access to the pshared field of a pthread_condrattr_t More...
 
const Access< Condition, ClockCLOCK
 provides access to the clock field of a pthread_condrattr_t More...
 
const Access< Thread, DetachStateDETACH_STATE
 provides access to the detachstate field of a pthread_attr_t More...
 
const Access< Thread, GuardSizeGUARD_SIZE
 provides access to the guardsize field of a pthread_attr_t More...
 
const Access< Thread,
InheritSched
INHERIT_SCHED
 provides access to the inheritsched field of a pthread_attr_t More...
 
const Access< Mutex, PSharedM_PSHARED
 provides access to the pshared field of a pthread_mutexattr_t More...
 
const Access< Mutex,
PriorityCeiling
PRIORITY_CEILING
 provides access to the prioceil field of a pthread_mutexattr_t More...
 
const Access< Mutex, ProtocolPROTOCOL
 provides access to the protocol field of a pthread_mutexattr_t More...
 
const Access< Thread, SchedPolicySCHED_POLICY
 provides access to the schedpolicy field of a pthread_attr_t More...
 
const Access< Thread, ScopeSCOPE
 provides access to the scope field of a pthread_attr_t More...
 
const Access< Thread, StackSTACK
 provides access to the stack field of a pthread_attr_t, including stack address and size More...
 
const Access< Thread, StackSizeSTACK_SIZE
 provides access to the stacksize field of a pthread_attr_t More...
 
const Access< Mutex, TypeTYPE
 provides access to the type field of a pthread_mutexattr_t More...
 

Detailed Description

Wraps posix-threads (pthreads.h) with object oriented API.

Typedef Documentation

typedef TypeWrap<clockid_t, 0> pthreads::Clock

A unique type which acts just like clockid_t but is distinct in the eyes of the compiler.

Definition at line 43 of file condition_attr.h.

typedef TypeWrap<std::size_t, 0> pthreads::GuardSize

A unique type which acts just like size_t but is distinct in the eyes of the compiler.

Definition at line 42 of file thread_attr.h.

A unique type which acts just like an int but is distinct in the eyes of the compiler.

Definition at line 43 of file mutex_attr.h.

typedef TypeWrap<std::size_t, 1> pthreads::StackSize

A unique type which acts just like size_t but is distinct in the eyes of the compiler.

Definition at line 46 of file thread_attr.h.

Enumeration Type Documentation

controls whether a thread is created in a detached state, meaning that the thread will destroy itself when it finished running, and cannot be joined

Enumerator
DETACHED 

thread is started in a detached state, when thread terminates, memory is automatically freed

JOINABLE 

thread must be join()ed by another thread for memory to be freed

INVALID_DETACH_STATE 

Definition at line 34 of file enums.h.

determines whether a thread inherits it's scheduling policy from the creating thread or if it uses the policy stored in the attribute object

Enumerator
INHERIT 

thread inherits scheduling policy from creating thread

EXPLICIT 

thread's scheduling policy is explicitly set in the Attr<Thread> object

INVALID_INHERIT_SCHED 

Definition at line 44 of file enums.h.

Which progocol is used for priority.

Enumerator
PRIO_NONE 
PRIO_INHERIT 
PRIO_PROTECT 
INVALID_PROTOCOL 

Definition at line 80 of file enums.h.

indicates whether or not a resource is shared across processes

Enumerator
SHARED 

resource is shared by all processes who have access to the memory containing the resource handle

PRIVATE 

resource is private to the creating process

INVALID_PSHARED 

Definition at line 72 of file enums.h.

if multiple threads are waiting on the same mutex, the Scheduling Policy determines the order in which they are aquired

Enumerator
OTHER 
FIFO 
RR 
BATCH 
IDLE 
SPORADIC 
INVALID_SCHED_POLICY 

Definition at line 54 of file enums.h.

Signifies process or system scheduling contention scope.

Enumerator
SYSTEM 
PROCESS 
INVALID_SCOPE 

Definition at line 65 of file enums.h.

Types of mutexes.

Enumerator
NORMAL 
ERROR_CHECK 
RECURSIVE 
DEFAULT 
INVALID_TYPE 

Definition at line 88 of file enums.h.

Function Documentation

template<class T >
void* pthreads::callCallable ( void *  obj)

function which invokes a callable object when that object is passed to launch a thread

Definition at line 38 of file thread.h.

template<typename Enum >
Enum pthreads::getEnum ( int  val)

returns the pthread integer enumerator that corresponds to the specified value

template<typename Enum >
int* pthreads::getEnumMap ( )

returns pointer to a map from enums to pthread enums (ints)

template<typename Enum >
int pthreads::mapEnum ( Enum  val)
inline

returns the pthread integer enumerator that corresponds to the specified value

Definition at line 103 of file enums.h.

Variable Documentation

const Access<Barrier, PShared> pthreads::B_PSHARED

provides access to the pshared field of a pthread_barrierattr_t

const Access<Condition, PShared> pthreads::C_PSHARED

provides access to the pshared field of a pthread_condrattr_t

const Access<Condition, Clock> pthreads::CLOCK

provides access to the clock field of a pthread_condrattr_t

const Access<Thread, DetachState> pthreads::DETACH_STATE

provides access to the detachstate field of a pthread_attr_t

const Access<Thread, GuardSize> pthreads::GUARD_SIZE

provides access to the guardsize field of a pthread_attr_t

const Access<Thread, InheritSched> pthreads::INHERIT_SCHED

provides access to the inheritsched field of a pthread_attr_t

const Access<Mutex, PShared> pthreads::M_PSHARED

provides access to the pshared field of a pthread_mutexattr_t

const Access<Mutex, PriorityCeiling> pthreads::PRIORITY_CEILING

provides access to the prioceil field of a pthread_mutexattr_t

const Access<Mutex, Protocol> pthreads::PROTOCOL

provides access to the protocol field of a pthread_mutexattr_t

const Access<Thread, SchedPolicy> pthreads::SCHED_POLICY

provides access to the schedpolicy field of a pthread_attr_t

const Access<Thread, Scope> pthreads::SCOPE

provides access to the scope field of a pthread_attr_t

const Access<Thread, Stack> pthreads::STACK

provides access to the stack field of a pthread_attr_t, including stack address and size

const Access<Thread, StackSize> pthreads::STACK_SIZE

provides access to the stacksize field of a pthread_attr_t

const Access<Mutex, Type> pthreads::TYPE

provides access to the type field of a pthread_mutexattr_t