Nektar++
Public Member Functions | Private Attributes | List of all members
Nektar::Thread::ThreadManagerStd::Barrier Class Reference

Lightweight barrier class. More...

Public Member Functions

 Barrier (std::size_t iCount)
 
void Wait ()
 

Private Attributes

std::mutex mMutex
 
std::condition_variable mCond
 
std::size_t mThreshold
 
std::size_t mCount
 
std::size_t mGeneration
 

Detailed Description

Lightweight barrier class.

Definition at line 60 of file ThreadStd.h.

Constructor & Destructor Documentation

◆ Barrier()

Nektar::Thread::ThreadManagerStd::Barrier::Barrier ( std::size_t  iCount)
inlineexplicit

Definition at line 63 of file ThreadStd.h.

Member Function Documentation

◆ Wait()

void Nektar::Thread::ThreadManagerStd::Barrier::Wait ( )
inline

Definition at line 68 of file ThreadStd.h.

69 {
70 std::unique_lock<std::mutex> lLock{mMutex};
71 auto lGen = mGeneration;
72 if (!--mCount)
73 {
76 mCond.notify_all();
77 }
78 else
79 {
80 mCond.wait(lLock, [this, lGen] { return lGen != mGeneration; });
81 }
82 }

References mCond, mCount, mGeneration, mMutex, and mThreshold.

Referenced by Nektar::Thread::ThreadManagerStd::v_Hold().

Member Data Documentation

◆ mCond

std::condition_variable Nektar::Thread::ThreadManagerStd::Barrier::mCond
private

Definition at line 86 of file ThreadStd.h.

Referenced by Wait().

◆ mCount

std::size_t Nektar::Thread::ThreadManagerStd::Barrier::mCount
private

Definition at line 88 of file ThreadStd.h.

Referenced by Wait().

◆ mGeneration

std::size_t Nektar::Thread::ThreadManagerStd::Barrier::mGeneration
private

Definition at line 89 of file ThreadStd.h.

Referenced by Wait().

◆ mMutex

std::mutex Nektar::Thread::ThreadManagerStd::Barrier::mMutex
private

Definition at line 85 of file ThreadStd.h.

Referenced by Wait().

◆ mThreshold

std::size_t Nektar::Thread::ThreadManagerStd::Barrier::mThreshold
private

Definition at line 87 of file ThreadStd.h.

Referenced by Wait().