38#include "blocxx/BLOCXX_config.h"
45#if defined(BLOCXX_USE_PTHREAD) && defined(BLOCXX_HAVE_PTHREAD_BARRIER) && !defined(BLOCXX_VALGRIND_SUPPORT)
61#if defined(BLOCXX_USE_PTHREAD) && defined(BLOCXX_HAVE_PTHREAD_BARRIER) && !defined(BLOCXX_VALGRIND_SUPPORT)
68 memset(&barrier, 0,
sizeof(barrier));
69 int res = pthread_barrier_init(&barrier, NULL, threshold);
77 int res = pthread_barrier_destroy(&barrier);
86 int res = pthread_barrier_wait(&barrier);
87 if (res != 0 && res != PTHREAD_BARRIER_SERIAL_THREAD)
89 BLOCXX_THROW(ThreadBarrierException, Format(
"pthread_barrier_wait failed: %1(%2)", res, strerror(res)).c_str());
93 pthread_barrier_t barrier;
#define BLOCXX_ASSERT(CON)
BLOCXX_ASSERT works similar to the assert() macro, but instead of calling abort(),...
#define BLOCXX_DEFINE_EXCEPTION_WITH_ID(NAME)
Define a new exception class named <NAME>Exception that derives from Exception.
#define BLOCXX_THROW(exType, msg)
Throw an exception using FILE and LINE.
The Condition class represents a synchronization device that allows threads to suspend execution and ...
void wait(NonRecursiveMutexLock &lock)
Atomically unlock a given mutex and wait for the this Condition object to get signalled.
void notifyAll()
Signal all threads that are currently waiting on the Condition object.
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
The ThreadBarrier class is used to synchronize threads.
ThreadBarrier & operator=(const ThreadBarrier &x)
IntrusiveReference< ThreadBarrierImpl > m_impl
ThreadBarrier(UInt32 threshold)
Constructor.
void wait()
Synchronize participating threads at the barrier.
NonRecursiveMutex m_mutex
ThreadBarrierImpl(UInt32 threshold)
UInt32 m_threshold
The number of threads to synchronize.
int m_curSubBarrier
Either 0 or 1, depending on whether we are the first generation of waiters or the next generation of ...
This code is inspired by ACE, by Douglas C.
Condition m_cond
Condition for threads to wait on.
UInt32 m_waitingCount
The number of waiting threads.