// Class static attributes initialisation
LocalTraceBufferPool* LocalTraceBufferPool::_singleton = 0;
-#ifndef WNT
-pthread_mutex_t LocalTraceBufferPool::_singletonMutex;
-#else
+//#ifndef WNT
+//pthread_mutex_t LocalTraceBufferPool::_singletonMutex;
+//#else
pthread_mutex_t LocalTraceBufferPool::_singletonMutex =
PTHREAD_MUTEX_INITIALIZER;
-#endif
+//#endif
BaseTraceCollector *LocalTraceBufferPool::_myThreadTrace = 0;
// ============================================================================
// wait until there is a free buffer in the pool
- int ret = sem_wait(&_freeBufferSemaphore);
+ int ret = -1;
+ while (ret)
+ {
+ ret = sem_wait(&_freeBufferSemaphore);
+ if (ret) perror(" LocalTraceBufferPool::insert, sem_wait");
+ }
// get the next free buffer available (mutex protected)
// wait until there is a buffer in the pool, with a message to print
- int ret = sem_wait(&_fullBufferSemaphore);
+ int ret = -1;
+ while (ret)
+ {
+ ret = sem_wait(&_fullBufferSemaphore);
+ if (ret) perror(" LocalTraceBufferPool::retrieve, sem_wait");
+ }
// get the next buffer to print
{
int ret;
ret = pthread_mutex_lock(&_incrementMutex); // lock access to counters
- pos++;
+ unsigned long mypos = ++pos;
ret = pthread_mutex_unlock(&_incrementMutex); // release lock
- return pos;
+ return mypos;
}