#include <LocalTraceBufferPool.hxx>
Public Member Functions | |
int | insert (int traceType, const char *msg) |
Called by trace producers within their threads. More... | |
int | retrieve (LocalTrace_TraceInfo &aTrace) |
Called by the thread in charge of printing trace messages. More... | |
unsigned long | toCollect () |
Gives the number of buffers to print. More... | |
Static Public Member Functions | |
static LocalTraceBufferPool * | instance () |
Guarantees a unique object instance of the class (singleton thread safe). More... | |
static void | deleteInstance (PROTECTED_DELETE *anObject) |
deleteInstance deletes only once the object. More... | |
static void | addObj (PROTECTED_DELETE *anObject) |
To allow a further destruction of a PRTECTED_DELETE object, it must be added to the static list of PROTECTED_DELETE*. More... | |
Protected Member Functions | |
LocalTraceBufferPool () | |
Constructor : initialize pool of buffers, semaphores and mutex. More... | |
virtual | ~LocalTraceBufferPool () |
Destructor : release memory associated with semaphores and mutex. More... | |
unsigned long | lockedIncrement (unsigned long &pos) |
pool counters are incremented under a mutex protection More... | |
Static Protected Attributes | |
static std::list < PROTECTED_DELETE * > | _objList |
Private Attributes | |
LocalTrace_TraceInfo | _myBuffer [512] |
sem_t | _freeBufferSemaphore |
sem_t | _fullBufferSemaphore |
pthread_mutex_t | _incrementMutex |
unsigned long | _position |
unsigned long | _insertPos |
unsigned long | _retrievePos |
Static Private Attributes | |
static LocalTraceBufferPool * | _singleton = 0 |
static pthread_mutex_t | _singletonMutex |
static BaseTraceCollector * | _myThreadTrace = 0 |
|
protected |
Constructor : initialize pool of buffers, semaphores and mutex.
References _freeBufferSemaphore, _fullBufferSemaphore, _incrementMutex, _insertPos, _myBuffer, _position, _retrievePos, IMMEDIATE_ABORT, MAXMESS_LENGTH, TRACE_BUFFER_SIZE, and TRUNCATED_MESSAGE.
Referenced by instance().
|
protectedvirtual |
Destructor : release memory associated with semaphores and mutex.
References _freeBufferSemaphore, _fullBufferSemaphore, _incrementMutex, _myThreadTrace, _singleton, _singletonMutex, and DEVTRACE.
|
staticinherited |
To allow a further destruction of a PRTECTED_DELETE object, it must be added to the static list of PROTECTED_DELETE*.
References PROTECTED_DELETE::_objList, and DEVTRACE.
Referenced by DESTRUCTOR_OF< TYPE >::DESTRUCTOR_OF().
|
staticinherited |
deleteInstance deletes only once the object.
Only object present on the static list of PROTECTED_DELETE* are deleted, then removed of the list. The operation is protected by a mutex.
References PROTECTED_DELETE::_listMutex, PROTECTED_DELETE::_objList, and DEVTRACE.
Referenced by DESTRUCTOR_OF< TYPE >::operator()(), UtilsTest::setUp(), LifeCycleCORBATest::setUp(), NamingServiceTest::setUp(), UtilsTest::tearDown(), LifeCycleCORBATest::tearDown(), NamingServiceTest::tearDown(), SALOMETraceCollectorTest::testLoadBufferPoolCORBA(), SALOMELocalTraceTest::testLoadBufferPoolFile(), SALOMELocalTraceTest::testLoadBufferPoolLocal(), and SALOMELocalTraceTest::testSingletonBufferPool().
int LocalTraceBufferPool::insert | ( | int | traceType, |
const char * | msg | ||
) |
Called by trace producers within their threads.
The trace message is copied in specific buffer from a circular pool of buffers. Waits until there is a free buffer in the pool, gets the first available buffer, fills it with the message. Messages are printed in a separate thread (see retrieve method)
References _freeBufferSemaphore, _fullBufferSemaphore, _insertPos, _myBuffer, _position, lockedIncrement(), MAXMESS_LENGTH, LocalTrace_TraceInfo::position, LocalTrace_TraceInfo::threadId, TRACE_BUFFER_SIZE, LocalTrace_TraceInfo::traceType, and traceType.
Referenced by FileTraceCollector::~FileTraceCollector(), LocalTraceCollector::~LocalTraceCollector(), and SALOMETraceCollector::~SALOMETraceCollector().
|
static |
Guarantees a unique object instance of the class (singleton thread safe).
When the LocalTraceBufferPool instance is created, the trace collector is also created (singleton). Type of trace collector to create depends on environment variable "SALOME_trace":
References _myThreadTrace, _singleton, _singletonMutex, DEVTRACE, LocalTraceCollector::instance(), FileTraceCollector::instance(), and LocalTraceBufferPool().
Referenced by ATEXIT_::ATEXIT_(), LocalTraceCollector::run(), FileTraceCollector::run(), SALOMETraceCollector::run(), UtilsTest::setUp(), LifeCycleCORBATest::setUp(), NamingServiceTest::setUp(), UtilsTest::tearDown(), LifeCycleCORBATest::tearDown(), NamingServiceTest::tearDown(), SALOMETraceCollectorTest::testLoadBufferPoolCORBA(), SALOMELocalTraceTest::testLoadBufferPoolFile(), SALOMELocalTraceTest::testLoadBufferPoolLocal(), SALOMELocalTraceTest::testSingletonBufferPool(), FileTraceCollector::~FileTraceCollector(), LocalTraceCollector::~LocalTraceCollector(), and SALOMETraceCollector::~SALOMETraceCollector().
|
protected |
pool counters are incremented under a mutex protection
References _incrementMutex.
Referenced by insert(), and retrieve().
int LocalTraceBufferPool::retrieve | ( | LocalTrace_TraceInfo & | aTrace | ) |
Called by the thread in charge of printing trace messages.
Waits until there is a buffer with a message to print. Gets the first buffer to print, copies it int the provided buffer
References _freeBufferSemaphore, _fullBufferSemaphore, _myBuffer, _retrievePos, lockedIncrement(), MESSAGE, and TRACE_BUFFER_SIZE.
Referenced by LocalTraceCollector::run(), FileTraceCollector::run(), and SALOMETraceCollector::run().
unsigned long LocalTraceBufferPool::toCollect | ( | ) |
Gives the number of buffers to print.
Usage : when the thread in charge of messages print id to be stopped, check if there is still something to print, before stop. There is no need of mutex here, provided there is only one thread to retrieve and print the buffers.
References _insertPos, and _retrievePos.
Referenced by LocalTraceCollector::run(), FileTraceCollector::run(), and SALOMETraceCollector::run().
|
private |
Referenced by insert(), LocalTraceBufferPool(), retrieve(), and ~LocalTraceBufferPool().
|
private |
Referenced by insert(), LocalTraceBufferPool(), retrieve(), and ~LocalTraceBufferPool().
|
private |
Referenced by LocalTraceBufferPool(), lockedIncrement(), and ~LocalTraceBufferPool().
|
private |
Referenced by insert(), LocalTraceBufferPool(), and toCollect().
|
private |
Referenced by insert(), LocalTraceBufferPool(), and retrieve().
|
staticprivate |
Referenced by instance(), and ~LocalTraceBufferPool().
|
staticprotectedinherited |
Referenced by PROTECTED_DELETE::addObj(), and PROTECTED_DELETE::deleteInstance().
|
private |
Referenced by insert(), and LocalTraceBufferPool().
|
private |
Referenced by LocalTraceBufferPool(), retrieve(), and toCollect().
|
staticprivate |
Referenced by instance(), and ~LocalTraceBufferPool().
|
staticprivate |
Referenced by instance(), and ~LocalTraceBufferPool().