The Pedigree Project 0.1
Classes | Public Member Functions | Private Member Functions | 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
 
bool m_Open
 
size_t m_ActiveOperations
 

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 84 of file OperationBarrier.cc.

Referenced by closeAndWait(), NetworkStack::deRegisterDevice(), UnixSocketSyscalls::lastDescriptorClosed(), and VFS::retireOwnedFilesystem().

+ Here is the caller graph for this function:

◆ closeAndWait()

void OperationBarrier::closeAndWait ( )

Atomically closes admission and waits for admitted work.

Definition at line 116 of file OperationBarrier.cc.

References close(), and wait().

Referenced by Process::closeDeferredTimeAccounting(), NetworkSyscalls::lastDescriptorClosed(), LwipSocketSyscalls::lastDescriptorClosed(), MqueueNetlinkSocket::lastDescriptorClosed(), ScsiController::shutdownDiskCaches(), and Process::~Process().

+ Here is the caller graph for this function:

◆ isClosedAndDrained()

bool OperationBarrier::isClosedAndDrained ( )

Definition at line 126 of file OperationBarrier.cc.

◆ isOpen()

bool OperationBarrier::isOpen ( )

Definition at line 121 of file OperationBarrier.cc.

◆ leave()

void OperationBarrier::leave ( )

Completes one successfully admitted operation.

Definition at line 73 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 89 of file OperationBarrier.cc.

◆ tryEnter()

bool OperationBarrier::tryEnter ( )

Attempts to admit one operation without blocking.

Definition at line 53 of file OperationBarrier.cc.

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 98 of file OperationBarrier.cc.

References panic().

Referenced by closeAndWait(), and NetworkStack::deRegisterDevice().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_ActiveOperations

size_t OperationBarrier::m_ActiveOperations
private

Definition at line 87 of file OperationBarrier.h.

◆ m_Open

bool OperationBarrier::m_Open
private

Definition at line 86 of file OperationBarrier.h.

◆ m_Waiters

WaitQueue OperationBarrier::m_Waiters
private

Definition at line 85 of file OperationBarrier.h.


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