The Pedigree Project 0.1
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
WaitQueue::Guard Class Reference
+ Collaboration diagram for WaitQueue::Guard:

Public Member Functions

 Guard (Guard &&other) noexcept
 
void prepareToWait ()
 
MUST_USE_RESULT WakeReason wait (const Channel &channel=Channel(), size_t debugState=0, uintptr_t debugAddress=0, StackDiscardCleanup onStackDiscard=nullptr, void *stackDiscardContext=nullptr)
 
MUST_USE_RESULT WakeReason waitForCompletion (const Channel &channel=Channel(), size_t debugState=0, uintptr_t debugAddress=0)
 
MUST_USE_RESULT WakeReason waitAndUnlock (Mutex &mutex, const Channel &channel=Channel(), size_t debugState=0, uintptr_t debugAddress=0, StackDiscardCleanup onStackDiscard=nullptr, void *stackDiscardContext=nullptr)
 
MUST_USE_RESULT WakeReason waitAndUnlockForCompletion (Mutex &mutex, const Channel &channel=Channel(), size_t debugState=0, uintptr_t debugAddress=0)
 
bool wakeOne (WakeReason reason=WakeReason::Signalled, const Channel &channel=Channel())
 
size_t wakeAll (WakeReason reason=WakeReason::Signalled, const Channel &channel=Channel())
 
size_t wakeAndRequeue (const Channel &source, size_t wakeCount, const Channel &destination, size_t requeueCount)
 

Private Member Functions

 Guard (WaitQueue &queue)
 
 NOT_COPYABLE_OR_ASSIGNABLE (Guard)
 
MUST_USE_RESULT WakeReason waitWithoutEventDispatch (const Channel &channel, size_t debugState, uintptr_t debugAddress)
 
void queueSchedulerNotification (Waiter *waiter)
 
void release ()
 

Private Attributes

WaitQueuem_Queue
 
bool m_OwnsLock
 
Waiterm_pFirstReady
 
Waiterm_pLastReady
 

Friends

class WaitQueue
 
class PerProcessorScheduler
 

Detailed Description

Definition at line 60 of file WaitQueue.h.

Constructor & Destructor Documentation

◆ Guard() [1/2]

WaitQueue::Guard::Guard ( Guard &&  other)
noexcept

Definition at line 49 of file WaitQueue.cc.

◆ ~Guard()

WaitQueue::Guard::~Guard ( )

Definition at line 60 of file WaitQueue.cc.

◆ Guard() [2/2]

WaitQueue::Guard::Guard ( WaitQueue queue)
explicitprivate

Definition at line 39 of file WaitQueue.cc.

Member Function Documentation

◆ prepareToWait()

void WaitQueue::Guard::prepareToWait ( )

Enables wakeAllIfWaiting for this wait. Call before the final sequentially consistent predicate check, keeping this guard held until either abandoning the wait or enrolling with wait().

Definition at line 83 of file WaitQueue.cc.

◆ queueSchedulerNotification()

void WaitQueue::Guard::queueSchedulerNotification ( Waiter waiter)
private

Definition at line 92 of file WaitQueue.cc.

◆ release()

void WaitQueue::Guard::release ( )
private

Definition at line 64 of file WaitQueue.cc.

◆ wait()

WaitQueue::WakeReason WaitQueue::Guard::wait ( const Channel channel = Channel(),
size_t  debugState = 0,
uintptr_t  debugAddress = 0,
StackDiscardCleanup  onStackDiscard = nullptr,
void *  stackDiscardContext = nullptr 
)

Enrols and blocks the current thread. The Guard is consumed.

Definition at line 103 of file WaitQueue.cc.

Referenced by Process::suspendInternal(), and RequestQueue::work().

+ Here is the caller graph for this function:

◆ waitAndUnlock()

WaitQueue::WakeReason WaitQueue::Guard::waitAndUnlock ( Mutex mutex,
const Channel channel = Channel(),
size_t  debugState = 0,
uintptr_t  debugAddress = 0,
StackDiscardCleanup  onStackDiscard = nullptr,
void *  stackDiscardContext = nullptr 
)

Releases a caller mutex before enrolling and blocking. The mutex is reacquired before every returning outcome, including a pending process or thread exit.

Definition at line 137 of file WaitQueue.cc.

◆ waitAndUnlockForCompletion()

WaitQueue::WakeReason WaitQueue::Guard::waitAndUnlockForCompletion ( Mutex mutex,
const Channel channel = Channel(),
size_t  debugState = 0,
uintptr_t  debugAddress = 0 
)

Releases a caller mutex while waiting for an ownership/lifetime barrier. Terminal requests and signal events may wake the wait, but neither may abandon reacquisition of the caller mutex. A signal interruption remains visible to the caller after reacquisition.

Definition at line 150 of file WaitQueue.cc.

Referenced by ConditionVariable::waitForCompletion().

+ Here is the caller graph for this function:

◆ waitForCompletion()

WaitQueue::WakeReason WaitQueue::Guard::waitForCompletion ( const Channel channel = Channel(),
size_t  debugState = 0,
uintptr_t  debugAddress = 0 
)

Waits for an ownership/lifetime barrier which must complete before terminal thread teardown may consume the stack. Terminal requests wake the waiter but are deferred across subsequent enrolment until the caller's predicate is satisfied.

Definition at line 116 of file WaitQueue.cc.

Referenced by Thread::joinInternal(), RequestQueue::waitForPreallocated(), Process::waitUntilTerminationReapable(), and Process::~Process().

+ Here is the caller graph for this function:

◆ waitWithoutEventDispatch()

WaitQueue::WakeReason WaitQueue::Guard::waitWithoutEventDispatch ( const Channel channel,
size_t  debugState,
uintptr_t  debugAddress 
)
private

Leaves event selection to the caller after its wait predicate recheck.

Definition at line 126 of file WaitQueue.cc.

◆ wakeAll()

size_t WaitQueue::Guard::wakeAll ( WakeReason  reason = WakeReason::Signalled,
const Channel channel = Channel() 
)

Definition at line 172 of file WaitQueue.cc.

◆ wakeAndRequeue()

size_t WaitQueue::Guard::wakeAndRequeue ( const Channel source,
size_t  wakeCount,
const Channel destination,
size_t  requeueCount 
)

Moves waiters under the queue lock, preserving coherent debug snapshots.

Definition at line 182 of file WaitQueue.cc.

◆ wakeOne()

bool WaitQueue::Guard::wakeOne ( WakeReason  reason = WakeReason::Signalled,
const Channel channel = Channel() 
)

Definition at line 162 of file WaitQueue.cc.

Friends And Related Symbol Documentation

◆ PerProcessorScheduler

friend class PerProcessorScheduler
friend

Definition at line 119 of file WaitQueue.h.

◆ WaitQueue

friend class WaitQueue
friend

Definition at line 118 of file WaitQueue.h.

Member Data Documentation

◆ m_OwnsLock

bool WaitQueue::Guard::m_OwnsLock
private

Definition at line 131 of file WaitQueue.h.

◆ m_pFirstReady

Waiter* WaitQueue::Guard::m_pFirstReady
private

Definition at line 132 of file WaitQueue.h.

◆ m_pLastReady

Waiter* WaitQueue::Guard::m_pLastReady
private

Definition at line 133 of file WaitQueue.h.

◆ m_Queue

WaitQueue* WaitQueue::Guard::m_Queue
private

Definition at line 130 of file WaitQueue.h.


The documentation for this class was generated from the following files: