Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::semaphore_units< ExceptionFactory, Clock > Class Template Reference

Public Member Functions

 semaphore_units (basic_semaphore< ExceptionFactory, Clock > &sem, size_t n) noexcept
 
 semaphore_units (semaphore_units &&o) noexcept
 
semaphore_unitsoperator= (semaphore_units &&o) noexcept
 
 semaphore_units (const semaphore_units &)=delete
 
size_t return_units (size_t units)
 
void return_all () noexcept
 Return ownership of all units. The semaphore will be signaled by the number of units returned.
 
size_t release () noexcept
 
semaphore_units split (size_t units)
 
void adopt (semaphore_units &&other) noexcept
 
size_t count () const noexcept
 Returns the number of units held.
 
 operator bool () const noexcept
 Returns true iff there any units held.
 

Member Function Documentation

◆ adopt()

template<typename ExceptionFactory = semaphore_default_exception_factory, typename Clock = typename timer<>::clock>
void seastar::semaphore_units< ExceptionFactory, Clock >::adopt ( semaphore_units< ExceptionFactory, Clock > &&  other)
inlinenoexcept

The inverse of split(), in which the units held by the specified semaphore_units object are merged into the current one. The function assumes (and asserts) that both are associated with the same semaphore.

Returns
the updated semaphore_units object

◆ release()

template<typename ExceptionFactory = semaphore_default_exception_factory, typename Clock = typename timer<>::clock>
size_t seastar::semaphore_units< ExceptionFactory, Clock >::release ( )
inlinenoexcept

Releases ownership of the units. The semaphore will not be signalled.

Returns
the number of units held

◆ return_units()

template<typename ExceptionFactory = semaphore_default_exception_factory, typename Clock = typename timer<>::clock>
size_t seastar::semaphore_units< ExceptionFactory, Clock >::return_units ( size_t  units)
inline

Return ownership of some units to the semaphore. The semaphore will be signaled by the number of units returned.

Parameters
unitsnumber of units to subtract.
Note
throws exception if units is more than those protected by the semaphore
Returns
the number of remaining units

◆ split()

template<typename ExceptionFactory = semaphore_default_exception_factory, typename Clock = typename timer<>::clock>
semaphore_units seastar::semaphore_units< ExceptionFactory, Clock >::split ( size_t  units)
inline

Splits this instance into a semaphore_units object holding the specified amount of units. This object will continue holding the remaining units.

Parameters
unitsnumber of units to subtract.
Note
throws exception if units is more than those protected by the semaphore
Returns
semaphore_units holding the specified number of units

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