Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
contur::Semaphore Class Referencefinal

Counting semaphore synchronization primitive. More...

#include <semaphore.h>

Inheritance diagram for contur::Semaphore:

Public Member Functions

 Semaphore (std::size_t initialCount=1, std::size_t maxCount=1)
 Constructs semaphore with initial and maximum count.
 ~Semaphore () override
 Destroys semaphore.
 Semaphore (const Semaphore &)=delete
 Copy construction is disabled.
Semaphoreoperator= (const Semaphore &)=delete
 Copy assignment is disabled.
 Semaphore (Semaphore &&) noexcept
 Move-constructs semaphore state.
Semaphoreoperator= (Semaphore &&) noexcept
 Move-assigns semaphore state.
Result< void > acquire (ProcessId pid) override
 Acquires one semaphore unit.
Result< void > release (ProcessId pid) override
 Releases one semaphore unit.
Result< void > tryAcquire (ProcessId pid) override
 Non-blocking acquire attempt.
std::string_view name () const noexcept override
 Primitive name for diagnostics.
SyncLayer layer () const noexcept override
 Layer classification for synchronization model split.
Result< void > registerProcessPriority (ProcessId pid, PriorityLevel basePriority)
 Registers process base priority used for boost rules.
PriorityLevel effectivePriority (ProcessId pid) const noexcept
 Effective priority after inheritance boosts.
PriorityLevel basePriority (ProcessId pid) const noexcept
 Registered base priority.
std::size_t count () const noexcept
 Current available count.
std::size_t maxCount () const noexcept
 Configured maximum count.
std::size_t waitingCount () const noexcept
 Number of waiting processes.
Public Member Functions inherited from contur::ISyncPrimitive
virtual ~ISyncPrimitive ()=default

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Counting semaphore synchronization primitive.

Definition at line 14 of file semaphore.h.

Constructor & Destructor Documentation

◆ Semaphore() [1/3]

contur::Semaphore::Semaphore ( std::size_t initialCount = 1,
std::size_t maxCount = 1 )
explicit

Constructs semaphore with initial and maximum count.

References maxCount().

Referenced by operator=(), operator=(), Semaphore(), and Semaphore().

◆ ~Semaphore()

contur::Semaphore::~Semaphore ( )
override

Destroys semaphore.

◆ Semaphore() [2/3]

contur::Semaphore::Semaphore ( const Semaphore & )
delete

Copy construction is disabled.

References Semaphore().

◆ Semaphore() [3/3]

contur::Semaphore::Semaphore ( Semaphore && )
noexcept

Move-constructs semaphore state.

References Semaphore().

Member Function Documentation

◆ acquire()

Result< void > contur::Semaphore::acquire ( ProcessId pid)
nodiscardoverridevirtual

Acquires one semaphore unit.

Implements contur::ISyncPrimitive.

References acquire().

Referenced by acquire().

◆ basePriority()

PriorityLevel contur::Semaphore::basePriority ( ProcessId pid) const
nodiscardnoexcept

Registered base priority.

References basePriority().

Referenced by basePriority(), and registerProcessPriority().

◆ count()

std::size_t contur::Semaphore::count ( ) const
nodiscardnoexcept

Current available count.

References count().

Referenced by count().

◆ effectivePriority()

PriorityLevel contur::Semaphore::effectivePriority ( ProcessId pid) const
nodiscardnoexcept

Effective priority after inheritance boosts.

References effectivePriority().

Referenced by effectivePriority().

◆ layer()

SyncLayer contur::Semaphore::layer ( ) const
nodiscardoverridevirtualnoexcept

Layer classification for synchronization model split.

Implements contur::ISyncPrimitive.

References layer().

Referenced by layer().

◆ maxCount()

std::size_t contur::Semaphore::maxCount ( ) const
nodiscardnoexcept

Configured maximum count.

References maxCount().

Referenced by maxCount(), and Semaphore().

◆ name()

std::string_view contur::Semaphore::name ( ) const
nodiscardoverridevirtualnoexcept

Primitive name for diagnostics.

Implements contur::ISyncPrimitive.

References name().

Referenced by name().

◆ operator=() [1/2]

Semaphore & contur::Semaphore::operator= ( const Semaphore & )
delete

Copy assignment is disabled.

References Semaphore().

◆ operator=() [2/2]

Semaphore & contur::Semaphore::operator= ( Semaphore && )
noexcept

Move-assigns semaphore state.

References Semaphore().

◆ registerProcessPriority()

Result< void > contur::Semaphore::registerProcessPriority ( ProcessId pid,
PriorityLevel basePriority )
nodiscard

Registers process base priority used for boost rules.

References basePriority(), and registerProcessPriority().

Referenced by registerProcessPriority().

◆ release()

Result< void > contur::Semaphore::release ( ProcessId pid)
nodiscardoverridevirtual

Releases one semaphore unit.

Implements contur::ISyncPrimitive.

References release().

Referenced by release().

◆ tryAcquire()

Result< void > contur::Semaphore::tryAcquire ( ProcessId pid)
nodiscardoverridevirtual

Non-blocking acquire attempt.

Implements contur::ISyncPrimitive.

References tryAcquire().

Referenced by tryAcquire().

◆ waitingCount()

std::size_t contur::Semaphore::waitingCount ( ) const
nodiscardnoexcept

Number of waiting processes.

References waitingCount().

Referenced by waitingCount().

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::Semaphore::impl_
private

Definition at line 69 of file semaphore.h.


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