Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::async::AsyncSemaphore Class Reference

Asynchronous counting semaphore for cooperative coroutine concurrency throttling. More...

#include <Semaphore.hpp>

+ Collaboration diagram for corium::async::AsyncSemaphore:

Classes

struct  AcquireAwaiter
 Awaiter for acquiring a permit asynchronously. More...
 

Public Member Functions

AcquireAwaiter acquire () noexcept
 Acquire a permit asynchronously (suspends coroutine until permit is released).
 
 AsyncSemaphore (const AsyncSemaphore &)=delete
 
constexpr AsyncSemaphore (ptrdiff_t initialCount=1) noexcept
 Construct semaphore with initial available count.
 
ptrdiff_t available () const noexcept
 Available permit count.
 
AsyncSemaphoreoperator= (const AsyncSemaphore &)=delete
 
void release (ptrdiff_t update=1) noexcept
 Release one or more permits and resume waiting coroutines.
 
bool tryAcquire () noexcept
 Non-blocking attempt to acquire a permit.
 
 ~AsyncSemaphore ()=default
 

Detailed Description

Asynchronous counting semaphore for cooperative coroutine concurrency throttling.

Constructor & Destructor Documentation

◆ AsyncSemaphore() [1/2]

constexpr corium::async::AsyncSemaphore::AsyncSemaphore ( ptrdiff_t  initialCount = 1)
inlineexplicitconstexprnoexcept

Construct semaphore with initial available count.

Parameters
initialCountNumber of initial available permits.

◆ ~AsyncSemaphore()

corium::async::AsyncSemaphore::~AsyncSemaphore ( )
default

◆ AsyncSemaphore() [2/2]

corium::async::AsyncSemaphore::AsyncSemaphore ( const AsyncSemaphore )
delete

Member Function Documentation

◆ acquire()

AcquireAwaiter corium::async::AsyncSemaphore::acquire ( )
inlinenoexcept

Acquire a permit asynchronously (suspends coroutine until permit is released).

◆ available()

ptrdiff_t corium::async::AsyncSemaphore::available ( ) const
inlinenoexcept

Available permit count.

◆ operator=()

AsyncSemaphore & corium::async::AsyncSemaphore::operator= ( const AsyncSemaphore )
delete

◆ release()

void corium::async::AsyncSemaphore::release ( ptrdiff_t  update = 1)
inlinenoexcept

Release one or more permits and resume waiting coroutines.

Parameters
updateNumber of permits to return (default: 1).

◆ tryAcquire()

bool corium::async::AsyncSemaphore::tryAcquire ( )
inlinenoexcept

Non-blocking attempt to acquire a permit.

Returns
true if permit acquired; false if semaphore count is zero.
+ Here is the caller graph for this function:

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