37 #include <condition_variable> 62 explicit Barrier(uint32_t numThreads) : m_threadCount(numThreads) {
63 m_numThreadsReachedSync = 0;
73 std::unique_lock<std::mutex> lk(m_numThreadsReachedSyncLock);
76 m_numThreadsReachedSync++;
77 if (m_numThreadsReachedSync == m_threadCount) {
79 m_allThreadsReachedSync.notify_all();
80 m_numThreadsReachedSync = 0;
83 m_allThreadsReachedSync.wait(lk, [syncNr,
this]{
return syncNr !=
m_syncNumber; });
uint32_t m_threadCount
the number of threads in the group.
std::condition_variable m_allThreadsReachedSync
uint32_t m_numThreadsReachedSync
number of htreads that reached current synchronization point.
Representation of a barrier.
void threadSync()
Synchronizes the threads in the group.
std::mutex m_numThreadsReachedSyncLock
uint32_t m_syncNumber
number of current synchronization point.
Basic declarations, included by all source files.
Barrier(uint32_t numThreads)
Creates a barrier for a group of numThreads threads.
The namespace for all OGDF objects.