//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
if (_singleton == 0) // another thread may have got
{ // the lock after the first test
DEVTRACE("New buffer pool");
if (_singleton == 0) // another thread may have got
{ // the lock after the first test
DEVTRACE("New buffer pool");
- std::string impl_name = std::string ("lib") + traceKind + std::string(".dll");
- handle = LoadLibrary( impl_name.c_str() );
+ std::string impl_name = std::string ("lib") + traceKind + std::string(".dll");
+ handle = LoadLibraryA( impl_name.c_str() );
int ret = -1;
while (ret)
{
ret = sem_wait(&_freeBufferSemaphore);
if (ret) perror(" LocalTraceBufferPool::insert, sem_wait");
}
int ret = -1;
while (ret)
{
ret = sem_wait(&_freeBufferSemaphore);
if (ret) perror(" LocalTraceBufferPool::insert, sem_wait");
}
// get the next free buffer available (mutex protected)
unsigned long myInsertPos = lockedIncrement(_insertPos);
// get the next free buffer available (mutex protected)
unsigned long myInsertPos = lockedIncrement(_insertPos);
// increment the full buffer semaphore
// (if previously 0, awake thread in charge of trace)
// increment the full buffer semaphore
// (if previously 0, awake thread in charge of trace)
int ret = -1;
while (ret)
{
ret = sem_wait(&_fullBufferSemaphore);
if (ret) MESSAGE (" LocalTraceBufferPool::retrieve, sem_wait");
}
int ret = -1;
while (ret)
{
ret = sem_wait(&_fullBufferSemaphore);
if (ret) MESSAGE (" LocalTraceBufferPool::retrieve, sem_wait");
}
// threads are waiting to put a trace: the waken up thread is not
// necessarily the first thread to wait.
// threads are waiting to put a trace: the waken up thread is not
// necessarily the first thread to wait.
for (int i=0; i<TRACE_BUFFER_SIZE; i++)
strcpy(&(_myBuffer[i].trace[MAXMESS_LENGTH]),TRUNCATED_MESSAGE);
int ret;
for (int i=0; i<TRACE_BUFFER_SIZE; i++)
strcpy(&(_myBuffer[i].trace[MAXMESS_LENGTH]),TRUNCATED_MESSAGE);
int ret;
ret=sem_init(&_freeBufferSemaphore, 0, TRACE_BUFFER_SIZE); // all buffer free
if (ret!=0) IMMEDIATE_ABORT(ret);
ret=sem_init(&_fullBufferSemaphore, 0, 0); // 0 buffer full
if (ret!=0) IMMEDIATE_ABORT(ret);
ret=sem_init(&_freeBufferSemaphore, 0, TRACE_BUFFER_SIZE); // all buffer free
if (ret!=0) IMMEDIATE_ABORT(ret);
ret=sem_init(&_fullBufferSemaphore, 0, 0); // 0 buffer full
if (ret!=0) IMMEDIATE_ABORT(ret);
ret=pthread_mutex_init(&_incrementMutex,NULL); // default = fast mutex
if (ret!=0) IMMEDIATE_ABORT(ret);
ret=pthread_mutex_init(&_incrementMutex,NULL); // default = fast mutex
if (ret!=0) IMMEDIATE_ABORT(ret);
- int ret;
- ret=sem_destroy(&_freeBufferSemaphore);
- ret=sem_destroy(&_fullBufferSemaphore);
- ret=pthread_mutex_destroy(&_incrementMutex);
+#ifdef __APPLE__
+ dispatch_release(_freeBufferSemaphore);
+ dispatch_release(_fullBufferSemaphore);
+#else
+ sem_destroy(&_freeBufferSemaphore);
+ sem_destroy(&_fullBufferSemaphore);
+#endif
+ pthread_mutex_destroy(&_incrementMutex);