The Pedigree Project 0.1
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
WaitQueue Class Reference

#include <WaitQueue.h>

+ Collaboration diagram for WaitQueue:

Classes

struct  Channel
 
class  Guard
 
struct  Waiter
 

Public Types

enum class  WakeReason {
  Waiting , Signalled , Event , Unwinding ,
  Terminating , Spurious
}
 
using StackDiscardCleanup = void(*)(void *)
 
using AbandonCallback = StackDiscardCleanup
 

Public Member Functions

MUST_USE_RESULT Guard acquire ()
 
bool wakeOne (WakeReason reason=WakeReason::Signalled, const Channel &channel=Channel())
 
size_t wakeAll (WakeReason reason=WakeReason::Signalled, const Channel &channel=Channel())
 
size_t wakeAllIfWaiting (WakeReason reason=WakeReason::Signalled, const Channel &channel=Channel())
 
size_t waiterCount ()
 

Private Member Functions

WakeReason wait (Guard &guard, Mutex *mutex, const Channel &channel, size_t debugState, uintptr_t debugAddress, bool deferTerminal, bool dispatchEvents)
 
bool wakeOneLocked (Guard &guard, WakeReason reason, const Channel &channel)
 
size_t wakeAllLocked (Guard &guard, WakeReason reason, const Channel &channel)
 
size_t wakeAndRequeueLocked (Guard &guard, const Channel &source, size_t wakeCount, const Channel &destination, size_t requeueCount)
 
bool completeWaiter (Guard &guard, Waiter *waiter, WakeReason reason)
 
void removeWaiterLocked (Waiter *waiter)
 
void clearWaitIntentIfEmpty ()
 
void cancel (Waiter *waiter, WakeReason reason)
 

Static Private Member Functions

static void publishReady (Waiter *waiter)
 

Private Attributes

Spinlock m_Lock
 
Waiterm_pFirstWaiter
 
Waiterm_pLastWaiter
 
size_t m_WaiterCount
 
bool m_WaitIntent
 

Friends

class Thread
 

Detailed Description

Owns the complete transition between testing a wait predicate and blocking.

A Guard serialises the predicate with wakeOne/wakeAll. wait() consumes the Guard and installs a persistent wait record before releasing the queue lock. Consequently, a wake arriving before the scheduler commits Sleeping is retained and causes the scheduler to abort the sleep.

Definition at line 28 of file WaitQueue.h.

Member Typedef Documentation

◆ AbandonCallback

using WaitQueue::AbandonCallback = StackDiscardCleanup

Definition at line 34 of file WaitQueue.h.

◆ StackDiscardCleanup

using WaitQueue::StackDiscardCleanup = void (*)(void*)

Definition at line 33 of file WaitQueue.h.

Member Enumeration Documentation

◆ WakeReason

enum class WaitQueue::WakeReason
strong

Definition at line 36 of file WaitQueue.h.

Constructor & Destructor Documentation

◆ WaitQueue()

WaitQueue::WaitQueue ( )

Definition at line 192 of file WaitQueue.cc.

◆ ~WaitQueue()

WaitQueue::~WaitQueue ( )

Definition at line 199 of file WaitQueue.cc.

Member Function Documentation

◆ acquire()

MUST_USE_RESULT Guard WaitQueue::acquire ( )
inline

Definition at line 139 of file WaitQueue.h.

◆ cancel()

void WaitQueue::cancel ( Waiter waiter,
WakeReason  reason 
)
private

Definition at line 501 of file WaitQueue.cc.

◆ clearWaitIntentIfEmpty()

void WaitQueue::clearWaitIntentIfEmpty ( )
private

Definition at line 353 of file WaitQueue.cc.

◆ completeWaiter()

bool WaitQueue::completeWaiter ( Guard guard,
Waiter waiter,
WakeReason  reason 
)
private

Definition at line 431 of file WaitQueue.cc.

◆ publishReady()

void WaitQueue::publishReady ( Waiter waiter)
staticprivate

Definition at line 455 of file WaitQueue.cc.

◆ removeWaiterLocked()

void WaitQueue::removeWaiterLocked ( Waiter waiter)
private

Definition at line 474 of file WaitQueue.cc.

◆ wait()

WaitQueue::WakeReason WaitQueue::wait ( Guard guard,
Mutex mutex,
const Channel channel,
size_t  debugState,
uintptr_t  debugAddress,
bool  deferTerminal,
bool  dispatchEvents 
)
private

Definition at line 205 of file WaitQueue.cc.

◆ waiterCount()

size_t WaitQueue::waiterCount ( )

Definition at line 548 of file WaitQueue.cc.

◆ wakeAll()

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

Definition at line 338 of file WaitQueue.cc.

◆ wakeAllIfWaiting()

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

Skips an empty queue. Every matching waiter must use prepareToWait(), and the caller must publish its predicate with sequential consistency before calling this method. Ordinary wakeAll has no such requirement.

Definition at line 343 of file WaitQueue.cc.

References ProcessorBase::guardDeviceHardIrqOperation().

Referenced by Semaphore::release().

+ Here is the caller graph for this function:

◆ wakeAllLocked()

size_t WaitQueue::wakeAllLocked ( Guard guard,
WakeReason  reason,
const Channel channel 
)
private

Definition at line 377 of file WaitQueue.cc.

◆ wakeAndRequeueLocked()

size_t WaitQueue::wakeAndRequeueLocked ( Guard guard,
const Channel source,
size_t  wakeCount,
const Channel destination,
size_t  requeueCount 
)
private

Definition at line 394 of file WaitQueue.cc.

◆ wakeOne()

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

Definition at line 333 of file WaitQueue.cc.

◆ wakeOneLocked()

bool WaitQueue::wakeOneLocked ( Guard guard,
WakeReason  reason,
const Channel channel 
)
private

Definition at line 361 of file WaitQueue.cc.

Friends And Related Symbol Documentation

◆ Thread

friend class Thread
friend

Definition at line 169 of file WaitQueue.h.

Member Data Documentation

◆ m_Lock

Spinlock WaitQueue::m_Lock
private

Definition at line 243 of file WaitQueue.h.

◆ m_pFirstWaiter

Waiter* WaitQueue::m_pFirstWaiter
private

Definition at line 244 of file WaitQueue.h.

◆ m_pLastWaiter

Waiter* WaitQueue::m_pLastWaiter
private

Definition at line 245 of file WaitQueue.h.

◆ m_WaiterCount

size_t WaitQueue::m_WaiterCount
private

Definition at line 246 of file WaitQueue.h.

◆ m_WaitIntent

bool WaitQueue::m_WaitIntent
private

Definition at line 247 of file WaitQueue.h.


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