Defined in file: hzProcess.h

The hzProcess class holds information on the current thread. This is for the purpose of directing log messages and facilitating stack traces. An instance of hzProcess per thread is COMPULSORY in all programs based on the HadronZoo library, including single threaded programs.

This class employes the private sub-class _fncall_rec as follows:-

_fncall_rec

Constructors/Detructors

hzProcess*hzProcess(void)
NULL-TYPEhzProcess(void)Constructs a hzProcess instance. Sets the process and thread ids and registers the thread
void~hzProcess(void)
NULL-TYPE~hzProcess(void)Removes the hzProcess instance from thread register and destructs it.

Public Methods:

voidCallHistory(void)Exports recent call history for this thread if there is an available logfile. The stack trace assumes all functions are using the _hzfunc() macro. Arguments: None Returns: None
uint32_tCallSeq(void)
uint64_tFuncCallSeq(void)
const char*GetCaller(void)
const char*GetCurrFunc(void)
uint32_tGetId(void)
hzLogger*GetLog(void)
intGetTID(void)
uint32_tLevel(void)
voidPullFunction(void)This is called by the Return() macro is stack tracing is switched on. This removes the function as it exits from the function stack of the hzProcess (the thread calling the function) Arguments: None Returns: None
voidPushFunction(const char* funcname)This is called by the _hzfunc macro if stack tracing is switched on. This adds the function called to the function stack of the hzProcess (the thread calling the function) Returns: None
char*ScratchPad(int32_t nSize)Allocate a temporary char* buffer from the per-thread scratch pad. Scratch pad allocations do not require deconstruction as they are eventually overwritten by subsequent scratch-pad allocations. This allows functions to use char* automatic variables to return string values to the caller, in string space that is not deleted on return of the function - without requiring the caller to delete the space. A common use of this technique, is where a printf-type function calls other functions during argument processing. The scratch pad is 16K and imposes a limit of 2K on individual allocations. With the proviso that the applicable thread has a hzProcess instance associated with it (nothing much will work otherwise), and with the proviso that the request for 2K or less, this allocation function will always succeed.
voidSetLog(hzLogger* pLog)
voidStackTrace(void)Exports stack trace for this thread if there is an available logfile. The stack trace assumes all functions are using the _hzfunc() macro. Arguments: None Returns: None
void_deregister(hzProcess* pProc)Removes the current thread from the register. The thread register must always be in order of thread id so to this end, this function copies the thread pointers from the current thread register array to a new array, omiting the deprecated thread. It then swaps the active thread register pointer (used to lookup threads), to the new array. // //
void_register(hzProcess* pProc)Register the current thread. The thread register must always be in order of thread id so to this end, this function copies the thread pointers from the current thread register array to a new array, inserting the new thread in it's appropriate position. It then swaps the active thread register pointer (used to lookup threads), to the new array.

Member Variables:

void*m_CurrentLockMemory location Microlock
uint64_t*m_FuncxFunction call id (function call seq no at point of call)
hzProcess::_fncall_rec*m_HistRecent function call history
uint32_tm_IdShort form ID (based on position in the global array of hzProcess instances)
hzEcodem_LastEcodeLast error code
hzStringm_LastErrmsgLast error message in current thread
char*m_ScratchScratch pad
const char**m_StackFunction call stack
intm_TIDThe current thread id
uint32_tm_nCallOsetCurrent offset into history
uint32_tm_nFuncsThe current function (current position in stack)
uint32_tm_nPeakFunction depth high water mark
uint32_tm_nScratchAdvnCurrent offset into scratch buffer (before allocation)
uint32_tm_nScratchOsetCurrent offset into scratch buffer (after allocation)
uint32_tm_nSeqCallFunction call sequence number
hzLogger*m_pLogThe default (first) logger for the thread