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

#include <OperationBarrier.h>

+ Collaboration diagram for OperationBarrier:

Classes

class  Lease
 

Public Member Functions

MUST_USE_RESULT bool tryEnter ()
 
MUST_USE_RESULT bool tryAcquire (Lease &lease)
 
void leave ()
 
void close ()
 
MUST_USE_RESULT bool tryCloseIfIdle ()
 
void wait ()
 
void closeAndWait ()
 
bool isOpen ()
 
bool isClosedAndDrained ()
 

Private Member Functions

 NOT_COPYABLE_OR_ASSIGNABLE (OperationBarrier)
 

Private Attributes

WaitQueue m_Waiters
 
size_t m_State
 

Static Private Attributes

static constexpr size_t Closed = size_t{1} << (sizeof(size_t) * 8 - 1)
 
static constexpr size_t CountMask = Closed - 1
 

Detailed Description

Closes admission to asynchronous work and drains work already admitted.

tryEnter() is safe in non-sleeping contexts. Every successful admission must have exactly one matching leave() after its final owner has stopped touching the protected object. Teardown closes admission before waiting, so late work is rejected without racing the final active operation.

Definition at line 23 of file OperationBarrier.h.

Constructor & Destructor Documentation

◆ OperationBarrier()

OperationBarrier::OperationBarrier ( )

Definition at line 44 of file OperationBarrier.cc.

◆ ~OperationBarrier()

OperationBarrier::~OperationBarrier ( )

Definition at line 46 of file OperationBarrier.cc.

Member Function Documentation

◆ close()

void OperationBarrier::close ( )

Rejects future admissions without waiting for existing work.

Definition at line 96 of file OperationBarrier.cc.

Referenced by ServiceManager::addService(), closeAndWait(), NetworkStack::deRegisterDevice(), UnixSocketSyscalls::lastDescriptorClosed(), VFS::removeDiskFilesystem(), ServiceManager::removeService(), and VFS::retireOwnedFilesystem().

+ Here is the caller graph for this function:

◆ closeAndWait()

void OperationBarrier::closeAndWait ( )

◆ isClosedAndDrained()

bool OperationBarrier::isClosedAndDrained ( )

Definition at line 136 of file OperationBarrier.cc.

◆ isOpen()

bool OperationBarrier::isOpen ( )

Definition at line 132 of file OperationBarrier.cc.

◆ leave()

void OperationBarrier::leave ( )

Completes one successfully admitted operation.

Definition at line 77 of file OperationBarrier.cc.

References panic().

Referenced by Uhci::cancelInterruptInAndDrain(), and Ohci::retireEDStorage().

+ Here is the caller graph for this function:

◆ tryAcquire()

bool OperationBarrier::tryAcquire ( Lease &  lease)

◆ tryCloseIfIdle()

bool OperationBarrier::tryCloseIfIdle ( )

Closes only when idle; a busy result leaves admission unchanged.

Definition at line 100 of file OperationBarrier.cc.

◆ tryEnter()

bool OperationBarrier::tryEnter ( )

Attempts to admit one operation without blocking.

Definition at line 53 of file OperationBarrier.cc.

References panic().

Referenced by Uhci::cancelAsyncAndDrain(), Ohci::doAsync(), Uhci::irq(), and tryAcquire().

+ Here is the caller graph for this function:

◆ wait()

void OperationBarrier::wait ( )

Waits for admitted work after close() has been called.

Definition at line 108 of file OperationBarrier.cc.

References panic().

Referenced by ServiceManager::addService(), closeAndWait(), NetworkStack::deRegisterDevice(), VFS::removeDiskFilesystem(), and ServiceManager::removeService().

+ Here is the caller graph for this function:

Member Data Documentation

◆ Closed

constexpr size_t OperationBarrier::Closed = size_t{1} << (sizeof(size_t) * 8 - 1)
staticconstexprprivate

Definition at line 85 of file OperationBarrier.h.

◆ CountMask

constexpr size_t OperationBarrier::CountMask = Closed - 1
staticconstexprprivate

Definition at line 86 of file OperationBarrier.h.

◆ m_State

size_t OperationBarrier::m_State
private

Definition at line 90 of file OperationBarrier.h.

◆ m_Waiters

WaitQueue OperationBarrier::m_Waiters
private

Definition at line 89 of file OperationBarrier.h.


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