Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
ThreadKey Class Reference

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. More...

#include <thread.h>

Collaboration diagram for ThreadKey:
Collaboration graph
[legend]

Public Member Functions

 ThreadKey ()
 Create a unique thread specific container. More...
 
virtual ~ThreadKey ()
 Destroy a thread specific container and any contents reserved. More...
 
void * getKey (void)
 Get the value of the pointer for the thread specific data container. More...
 
void setKey (void *)
 Set the value of the pointer for the current thread specific execution context. More...
 

Private Types

typedef void(* TDestruct )(void *)
 

Private Member Functions

 ThreadKey (TDestruct destruct)
 

Private Attributes

pthread_key_t key
 

Friends

class ThreadImpl
 

Detailed Description

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.

Finally, Common C++ supports a thread-safe "AtomicCounter" class. This can often be used for reference counting without having to protect the counter with a separate Mutex counter. This lends to lighter-weight code.

Author
David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m container for thread specific data storage.

Definition at line 1707 of file thread.h.

Member Typedef Documentation

typedef void(* ThreadKey::TDestruct)(void *)
private

Definition at line 1712 of file thread.h.

Constructor & Destructor Documentation

ThreadKey::ThreadKey ( TDestruct  destruct)
private
ThreadKey::ThreadKey ( )

Create a unique thread specific container.

virtual ThreadKey::~ThreadKey ( )
virtual

Destroy a thread specific container and any contents reserved.

Member Function Documentation

void* ThreadKey::getKey ( void  )

Get the value of the pointer for the thread specific data container.

A unique pointer can be set for each execution context.

Returns
a unique void * for each execution context.
void ThreadKey::setKey ( void *  )

Set the value of the pointer for the current thread specific execution context.

This can be used to store thread context specific data.

Parameters
-ptr to thread context specific data.

Friends And Related Function Documentation

friend class ThreadImpl
friend

Definition at line 1713 of file thread.h.

Field Documentation

pthread_key_t ThreadKey::key
private

Definition at line 1711 of file thread.h.


The documentation for this class was generated from the following file: