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-TYPE | hzProcess | (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:
| void | CallHistory | (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_t | CallSeq | (void) | |
| uint64_t | FuncCallSeq | (void) | |
| const char* | GetCaller | (void) | |
| const char* | GetCurrFunc | (void) | |
| uint32_t | GetId | (void) | |
| hzLogger* | GetLog | (void) | |
| int | GetTID | (void) | |
| uint32_t | Level | (void) | |
| void | PullFunction | (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 |
| void | PushFunction | (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. |
| void | SetLog | (hzLogger* pLog) | |
| void | StackTrace | (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_CurrentLock | Memory location Microlock | |
| uint64_t* | m_Funcx | Function call id (function call seq no at point of call) | |
| hzProcess::_fncall_rec* | m_Hist | Recent function call history | |
| uint32_t | m_Id | Short form ID (based on position in the global array of hzProcess instances) | |
| hzEcode | m_LastEcode | Last error code | |
| hzString | m_LastErrmsg | Last error message in current thread | |
| char* | m_Scratch | Scratch pad | |
| const char** | m_Stack | Function call stack | |
| int | m_TID | The current thread id | |
| uint32_t | m_nCallOset | Current offset into history | |
| uint32_t | m_nFuncs | The current function (current position in stack) | |
| uint32_t | m_nPeak | Function depth high water mark | |
| uint32_t | m_nScratchAdvn | Current offset into scratch buffer (before allocation) | |
| uint32_t | m_nScratchOset | Current offset into scratch buffer (after allocation) | |
| uint32_t | m_nSeqCall | Function call sequence number | |
| hzLogger* | m_pLog | The default (first) logger for the thread |