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

PsnCurrentActiveObject Class Reference

class CurrentActiveObject. More...

#include <PsnCurrentActiveObject.h>

List of all members.

Public Methods

 PsnCurrentActiveObject (const PsSimulatedObject *currentActiveObject)
 constructor: installs currentActiveObject on top of the global context

virtual ~PsnCurrentActiveObject ()
 destructor: uninstalls the currentActiveObject


Static Public Methods

pthread_key_t initialisePthreadKey ()
 a function to enble correct initialisation of thread safety keys

PsSimulatedObjectgetCurrentActiveObject ()

Static Public Attributes

pthread_key_t threadContextKey = PsnCurrentActiveObject::initialisePthreadKey()
 A key for a thread to access it's own context.


Protected Attributes

void * _oldName


Detailed Description

class CurrentActiveObject.

This class is used to keep a global context indicating to the current execution thread the simulated object the thread is executing code in behalf of. This class uses the same design pattern as HeapStackTop

Definition at line 29 of file PsnCurrentActiveObject.h.


Constructor & Destructor Documentation

PsnCurrentActiveObject::PsnCurrentActiveObject const PsSimulatedObject   currentActiveObject
 

constructor: installs currentActiveObject on top of the global context

Definition at line 34 of file PsnCurrentActiveObject.cxx.

References _oldName, and threadContextKey.

00035 {
00036   _oldName = pthread_getspecific( threadContextKey ) ;
00037   pthread_setspecific ( threadContextKey , currentActiveObject );   
00038 }

PsnCurrentActiveObject::~PsnCurrentActiveObject   [virtual]
 

destructor: uninstalls the currentActiveObject

Definition at line 40 of file PsnCurrentActiveObject.cxx.

References _oldName, and threadContextKey.

00041 {
00042   pthread_setspecific ( threadContextKey , _oldName );
00043 }


Member Function Documentation

PsSimulatedObject * PsnCurrentActiveObject::getCurrentActiveObject   [static]
 

Definition at line 46 of file PsnCurrentActiveObject.cxx.

References threadContextKey.

Referenced by PsInput< Type >::realConnect(), PsOutput< Type >::set(), PsGenericControlParameter< Type, AncestorClass >::set(), and PsAbstractInput< Type >::setConnectable().

00047 {
00048   return (PsSimulatedObject *) pthread_getspecific( threadContextKey ) ;
00049 }

pthread_key_t PsnCurrentActiveObject::initialisePthreadKey   [static]
 

a function to enble correct initialisation of thread safety keys

Definition at line 24 of file PsnCurrentActiveObject.cxx.

00025 {
00026    pthread_key_t res ;
00027    pthread_key_create( &res, NULL) ;
00028    pthread_setspecific ( res, NULL );
00029    return res ;
00030 }


Member Data Documentation

void* PsnCurrentActiveObject::_oldName [protected]
 

Definition at line 47 of file PsnCurrentActiveObject.h.

Referenced by PsnCurrentActiveObject(), and ~PsnCurrentActiveObject().

pthread_key_t PsnCurrentActiveObject::threadContextKey = PsnCurrentActiveObject::initialisePthreadKey() [static]
 

A key for a thread to access it's own context.

Use should be implicit, through creation and deletion of PsnCurrentActiveObjects

Definition at line 32 of file PsnCurrentActiveObject.cxx.

Referenced by getCurrentActiveObject(), PsnCurrentActiveObject(), and ~PsnCurrentActiveObject().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:25:57 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001