LRAUV  revA
PCaller Class Reference

Protected Caller. More...

#include <PCaller.h>

Collaboration diagram for PCaller:

Classes

class  Initializer
 
struct  PCallOperation
 

Public Types

enum  PCallOperationType {
  BLOCK_NO_OPERATION, BLOCK_INITIALIZE, BLOCK_EXECUTE, BLOCK_EXECUTE_IF_UNSATISFIED,
  BLOCK_UNINITIALIZE, PCALLER_START, PCALLER_TERMINATE
}
 

Public Member Functions

 PCaller (bool idleThread, Logger &logger)
 Constructor. More...
 
virtual ~PCaller ()
 Destructor. More...
 
bool pInitialize (Component &component)
 
bool pExecute (Component &component)
 
bool pExecuteIfUnsatisfied (Behavior &component, bool &satisfied)
 
bool pUninitialize (Component &component)
 

Private Member Functions

bool startThread ()
 
void stopThread ()
 
bool pCall (Component &component, PCallOperationType operation, bool *returnValue)
 Executes the specified method of this component with signal catching Returns true on normal run termination, false if a signal has occurred. More...
 
void containedWait ()
 The entry point for the protected thread. More...
 
void ownerWait ()
 Wait for another thread to activate this thread. More...
 
void yieldToContained ()
 Just yield execution to the waiting contained thread. More...
 
void yieldToOwner ()
 Just yield execution to the waiting owner thread. More...
 
 PCaller (const PCaller &old)
 

Static Private Member Functions

static void ShowInfo (Component *component, int signal, int errno, int code, size_t addr, size_t backtraceCount, char **backtraceStrings)
 
static const char * PCallOperationToChars (const PCallOperationType operation)
 
static void * PThreadRun (void *pCaller)
 
static void RegisterDefaultSignals (void)
 
static void DefaultSignalHandler (int signal, siginfo_t *sigIngo, void *context)
 
static const char * SignalMessage (int signal, int code)
 

Private Attributes

Loggerlogger_
 
Mutex pCallMutex_
 
Mutex threadConditionMutex_
 
ThreadCondition threadCondition_
 
pthread_t containedThread_
 
pthread_t ownerThread_
 
pthread_t runningThread_
 
ComponentcurrentComponent_
 
PCallOperation currentOperation_
 
pthread_attr_t threadAttributes_
 
bool threadRunning_
 
bool threadDone_
 
bool idle_
 

Static Private Attributes

static Initializer Initializer_
 Runs static intialization code. More...
 
static FlexArray< PCaller * > PCallers_
 

Detailed Description

Protected Caller.

Can be used by a Handler or Component to make signal-handling protected calls to the execute(), initialize(), or uninitialize() methods of a component.

Member Enumeration Documentation

Enumerator
BLOCK_NO_OPERATION 
BLOCK_INITIALIZE 
BLOCK_EXECUTE 
BLOCK_EXECUTE_IF_UNSATISFIED 
BLOCK_UNINITIALIZE 
PCALLER_START 
PCALLER_TERMINATE 

Constructor & Destructor Documentation

PCaller::PCaller ( const PCaller old)
private

Member Function Documentation

void PCaller::containedWait ( )
private

The entry point for the protected thread.

A static function. Wait for another thread to activate this thread.

References Mutex::lock(), runningThread_, threadCondition_, threadConditionMutex_, Mutex::unlock(), and ThreadCondition::wait().

Referenced by PThreadRun().

void PCaller::DefaultSignalHandler ( int  signal,
siginfo_t *  sigIngo,
void *  context 
)
staticprivate
void PCaller::ownerWait ( )
private

Wait for another thread to activate this thread.

References Mutex::lock(), runningThread_, threadCondition_, threadConditionMutex_, Mutex::unlock(), and ThreadCondition::wait().

Referenced by pCall(), and startThread().

const char * PCaller::PCallOperationToChars ( const PCallOperationType  operation)
staticprivate
bool PCaller::pExecute ( Component component)
inline

References BLOCK_EXECUTE, and pCall().

Referenced by Handler::run(), and MultiHandler::runNext().

bool PCaller::pExecuteIfUnsatisfied ( Behavior component,
bool &  satisfied 
)
inline
bool PCaller::pInitialize ( Component component)
inline
bool PCaller::pUninitialize ( Component component)
inline

References BLOCK_UNINITIALIZE, and pCall().

Referenced by Handler::run(), and MultiHandler::shutdown().

void PCaller::RegisterDefaultSignals ( void  )
staticprivate
void PCaller::ShowInfo ( Component component,
int  signal,
int  errno,
int  code,
size_t  addr,
size_t  backtraceCount,
char **  backtraceStrings 
)
staticprivate
const char * PCaller::SignalMessage ( int  signal,
int  code 
)
staticprivate

Referenced by DefaultSignalHandler(), and ShowInfo().

void PCaller::stopThread ( )
private

References containedThread_, and threadRunning_.

Referenced by startThread(), and ~PCaller().

void PCaller::yieldToContained ( )
private

Just yield execution to the waiting contained thread.

References containedThread_, Mutex::lock(), runningThread_, ThreadCondition::signal(), threadCondition_, threadConditionMutex_, and Mutex::unlock().

Referenced by pCall(), startThread(), and ~PCaller().

void PCaller::yieldToOwner ( )
private

Just yield execution to the waiting owner thread.

References Mutex::lock(), ownerThread_, runningThread_, ThreadCondition::signal(), threadCondition_, threadConditionMutex_, and Mutex::unlock().

Referenced by DefaultSignalHandler(), and PThreadRun().

Member Data Documentation

pthread_t PCaller::containedThread_
private
Component* PCaller::currentComponent_
private
PCallOperation PCaller::currentOperation_
private
bool PCaller::idle_
private

Referenced by startThread().

PCaller::Initializer PCaller::Initializer_
staticprivate

Runs static intialization code.

Logger& PCaller::logger_
private

Referenced by PThreadRun(), and startThread().

pthread_t PCaller::ownerThread_
private

Referenced by pCall(), and yieldToOwner().

FlexArray< PCaller * > PCaller::PCallers_
staticprivate
Mutex PCaller::pCallMutex_
private

Referenced by pCall().

pthread_t PCaller::runningThread_
private
pthread_attr_t PCaller::threadAttributes_
private

Referenced by PCaller(), startThread(), and ~PCaller().

ThreadCondition PCaller::threadCondition_
private
Mutex PCaller::threadConditionMutex_
private
bool PCaller::threadDone_
private

Referenced by PThreadRun().

bool PCaller::threadRunning_
private

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