carb::tasking::RecursiveMutexWrapper

Defined in carb/tasking/TaskingUtils.h

class RecursiveMutexWrapper

Wrapper for a recursive carb::tasking::Mutex that conforms to C++ Named Requirements of Lockable.

Public Functions

inline RecursiveMutexWrapper()

Constructs a new RecursiveMutexWrapper object.

inline RecursiveMutexWrapper(ITasking*)

Constructs a new RecursiveMutexWrapper object.

Note

Deprecated: ITasking no longer needed.

inline ~RecursiveMutexWrapper()

Destructor.

Warning

It is an error to destroy a mutex that is locked.

inline bool try_lock()

Attempts to lock the mutex immediately.

Returns

true if the mutex was locked or already owned by this thread/task; false otherwise. If true is returned, unlock() must be called to release the lock.

inline void lock()

Locks the mutex, waiting until it becomes available.

Call unlock() to release the lock.

inline void unlock()

Unlocks a mutex previously acquired with try_lock() or lock()

Note

The unlock() function must be called for each successful lock.

Warning

It is undefined behavior to unlock a mutex that is not owned by the current thread or task.

template<class Rep, class Period>
inline bool try_lock_for(const std::chrono::duration<Rep, Period> &duration)

Attempts to lock a mutex within a specified duration.

Parameters

duration – The duration to wait for the mutex to be available

Returns

true if the mutex was locked; false if the timeout period expired. If true is returned, unlock() must be called to release the lock.

template<class Clock, class Duration>
inline bool try_lock_until(const std::chrono::time_point<Clock, Duration> &time_point)

Attempts to lock a mutex waiting until a specific clock time.

Parameters

time_point – The clock time to wait until.

Returns

true if the mutex was locked; false if the timeout period expired. If true is returned, unlock() must be called to release the lock.

inline operator Mutex*() const

Convertible to Mutex*.

inline ITasking *getTasking() const

Returns the acquired ITasking interface that was used to construct this object.

Note

Deprecated: Use carb::getCachedInterface instead.