carb::tasking::MutexWrapper

Defined in carb/tasking/TaskingUtils.h

class MutexWrapper

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

Non-recursive. If a recursive mutex is desired, use RecursiveMutexWrapper.

Public Functions

inline MutexWrapper()

Constructs a new MutexWrapper object.

inline MutexWrapper(ITasking*)

Constructs a new MutexWrapper object.

Note

Deprecated: ITasking no longer needed.

inline ~MutexWrapper()

Destructor.

Warning

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

inline bool try_lock()

Attempts to lock the mutex immediately.

Warning

It is an error to lock recursively. Use RecursiveSharedMutex if recursive locking is desired.

Returns

true if the mutex was locked; false otherwise

inline void lock()

Locks the mutex, waiting until it becomes available.

Warning

It is an error to lock recursively. Use RecursiveSharedMutex if recursive locking is desired.

inline void unlock()

Unlocks a mutex previously acquired with try_lock() or 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.

Warning

It is an error to lock recursively. Use RecursiveSharedMutex if recursive locking is desired.

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

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.

Warning

It is an error to lock recursively. Use RecursiveSharedMutex if recursive locking is desired.

Parameters

time_point – The clock time to wait until.

Returns

true if the mutex was locked; false if the timeout period expired

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.