carb::tasking::SemaphoreWrapper¶
Defined in carb/tasking/TaskingUtils.h
-
class
carb::tasking
::
SemaphoreWrapper
¶ Wrapper for a carb::tasking::Semaphore.
Note
SemaphoreWrapper can be used for Throttling tasks.
Public Functions
-
inline
SemaphoreWrapper
(unsigned value)¶ Constructs a new SemaphoreWrapper object.
- Parameters
value – The initial value of the semaphore (i.e. how many times acquire() can be called without blocking).
-
inline
SemaphoreWrapper
(ITasking*, unsigned value)¶ Constructs a new SemaphoreWrapper object.
Note
Deprecated: ITasking no longer needed.
- Parameters
value – The initial value of the semaphore (i.e. how many times acquire() can be called without blocking).
-
inline
~SemaphoreWrapper
()¶ Destructor.
-
inline void
release
(unsigned count = 1)¶ Increases the value of the semaphore, potentially unblocking any threads waiting in acquire().
-
inline void
acquire
()¶ Reduce the value of the Semaphore by one, potentially blocking if the count is already zero.
-
inline bool
try_acquire
()¶ Attempts to reduce the value of the Semaphore by one.
If the Semaphore’s value is zero, false is returned.
- Returns
true if the count of the Semaphore was reduced by one; false if the count is already zero.
-
template<class
Rep
, classPeriod
>
inline booltry_acquire_for
(const std::chrono::duration<Rep, Period> &dur)¶ Attempts to reduce the value of the Semaphore by one, waiting until the duration expires if the value is zero.
- Returns
true if the count of the Semaphore was reduced by one; false if the duration expires.
-
template<class
Clock
, classDuration
>
inline booltry_acquire_until
(const std::chrono::time_point<Clock, Duration> &tp)¶ Attempts to reduce the value of the Semaphore by one, waiting until the given time point is reached if the value is zero.
- Returns
true if the count of the Semaphore was reduced by one; false if the time point is reached by the clock.
-
inline
operator Semaphore*
() const¶ Convertible to Semaphore*.
-
inline ITasking *
getTasking
() const¶ Returns the acquired ITasking interface that was used to construct this object.
Note
Deprecated: Use carb::getCachedInterface instead.
-
inline