CoopSync for TBB 0.1.0
Cooperative synchronization primitives for TBB resumable tasks
Loading...
Searching...
No Matches
coopsync_tbb Namespace Reference

Main namespace of the library, containing all public APIs. More...

Namespaces

namespace  alpaka
 alpaka integration.
namespace  cuda
 CUDA integration.
namespace  hip
 HIP integration.
namespace  onnx
 ONNX Runtime integration.

Classes

class  atomic_condition
 Wrapper around std::atomic that provides atomic waiting which suspends the calling task instead of blocking it. More...
class  atomic_flag
 Wrapper around std::atomic_flag that provides atomic waiting which suspends the calling task instead of blocking it, as well as exposing atomic test, set and clear operations. More...
class  atomic_ref_condition
 Wrapper around std::atomic_ref that provides atomic waiting which suspends the calling task instead of blocking it. More...
class  barrier
 A barrier is a reusable synchronization primitive that allows tasks to suspend until a certain number of arrivals have occurred. The barrier is reusable, meaning that once the expected number of arrivals has been reached and the completion function has been called, the barrier can be used again for the next phase. Concurrent invocations of the member functions. except for destructor, are safe. More...
class  condition_variable
 Condition variable used to synchronize tasks. The tasks can be suspended on this condition variable and then later notify to resume if given condition is met. More...
class  future_error
 Exception type thrown by future and promise operations. More...
class  future
 Future holding a shared state with a value type. Waiting or getting the value from a not ready state suspends the current task until the state becomes ready. After the value is retrieved, the future is left in not valid state and cannot be used again. More...
class  promise
 Promise holding a shared state with a value type. The promise is used to set the value in the shared state that can be retrieved by a future sharing the same state. More...
class  shared_future
 Copyable future that allows retrieving the result multiple times. More...
class  future< void >
 Specialization of future for void type. More...
class  future< T & >
 Specialization of future for reference types. More...
class  shared_future< void >
 Specialization of shared_future for void type. More...
class  shared_future< T & >
 Specialization of shared_future for reference types. More...
class  promise< void >
 Specialization of promise for void type. The promise<void> does not store a value, but only the state of readiness and any exception. More...
class  promise< T & >
 Specialization of promise for reference types. The promise<T&> stores a reference to a value of type T in the shared state. More...
class  packaged_task< R(Args...)>
 Class template wrapping a callable object and allowing to invoke it asynchronously, storing the result in a shared state that can be accessed through a future. More...
class  latch
 A latch is a down-ward counter that allows tasks to wait until the counter reaches zero. The latch is not reusable, i.e., once the counter reaches zero, it cannot be incremented again. Concurrent invocations of the member functions, except for destructor, are safe. More...
class  mutex
 A mutex that can be used to synchronize access to shared resources. The mutex is non-recursive and provides no fairness guarantees. An attempt to acquire a mutex that is already in acquired state suspends the calling task until the mutex can be acquired. More...
class  counting_semaphore
 A counting semaphore that allows tasks to synchronize based on a counter. The semaphore is initialized with a non-negative count, and tasks can acquire the semaphore by decrementing the count or release the semaphore by incrementing the count. If a task tries to acquire the semaphore when the count is zero, it is suspended until the count becomes greater than zero. Concurrent invocations of the member functions, except for destructor, are safe. More...
class  counting_semaphore< 1 >
 A specialization of a counting_semaphore handling only a single permit. Same as binary_semaphore. More...
class  shared_mutex
 A shared mutex that can be used to synchronize access to shared resources. The mutex can be acquired in exclusive (writer) mode (lock) or shared (reader) mode (lock_shared). The mutex is non-recursive and provides no fairness guarantees. More...

Typedefs

using binary_semaphore = counting_semaphore<1>
 An alias for counting_semaphore<1>.
using rw_mutex = shared_mutex
 Alias for shared_mutex, following the TBB convention of naming reader-writer mutexes.

Functions

template<typename T>
COOPSYNC_TBB_EXPORT void atomic_wait (atomic_condition< T > *object, typename atomic_condition< T >::value_type old)
 Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old).
template<typename T>
COOPSYNC_TBB_EXPORT void atomic_wait_explicit (atomic_condition< T > *object, typename atomic_condition< T >::value_type old, std::memory_order order)
 Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old, order).
template<typename T>
COOPSYNC_TBB_EXPORT void atomic_notify_one (atomic_condition< T > *object)
 Resumes one task suspended waiting on the atomic_condition, if there is any. Same as object->notify_one().
template<typename T>
COOPSYNC_TBB_EXPORT void atomic_notify_all (atomic_condition< T > *object)
 Resumes all tasks suspended waiting on the atomic_condition. Same as object->notify_all().
template<typename T>
void atomic_wait (atomic_condition< T > *object, typename atomic_condition< T >::value_type old)
 Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old).
template<typename T>
void atomic_wait_explicit (atomic_condition< T > *object, typename atomic_condition< T >::value_type old, std::memory_order order)
 Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old, order).
template<typename T>
void atomic_notify_one (atomic_condition< T > *object)
 Resumes one task suspended waiting on the atomic_condition, if there is any. Same as object->notify_one().
template<typename T>
void atomic_notify_all (atomic_condition< T > *object)
 Resumes all tasks suspended waiting on the atomic_condition. Same as object->notify_all().
COOPSYNC_TBB_EXPORT void atomic_flag_clear (atomic_flag *object) noexcept
 Atomically sets the state to clear. Same as object->clear().
COOPSYNC_TBB_EXPORT void atomic_flag_clear_explicit (atomic_flag *object, std::memory_order order) noexcept
 Atomically sets the state to clear. Same as object->clear(order).
COOPSYNC_TBB_EXPORT bool atomic_flag_test_and_set (atomic_flag *object) noexcept
 Atomically sets the state to set and returns the previous state. Same as object->test_and_set().
COOPSYNC_TBB_EXPORT bool atomic_flag_test_and_set_explicit (atomic_flag *object, std::memory_order order) noexcept
 Atomically sets the state to set and returns the previous state. Same as object->test_and_set(order).
COOPSYNC_TBB_EXPORT bool atomic_flag_test (atomic_flag *object) noexcept
 Atomically reads the current state and returns it. Same as object->test().
COOPSYNC_TBB_EXPORT bool atomic_flag_test_explicit (atomic_flag *object, std::memory_order order) noexcept
 Atomically reads the current state and returns it. Same as object->test(order).
COOPSYNC_TBB_EXPORT void atomic_flag_wait (atomic_flag *object, bool old)
 Suspends the calling task until the state is not equal to specified value. If the internal atomic the state is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the state is not equal to old. Same as object->wait(old).
COOPSYNC_TBB_EXPORT void atomic_flag_wait_explicit (atomic_flag *object, bool old, std::memory_order order)
 Suspends the calling task until the state is not equal to specified value. If the internal atomic the state is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the state is not equal to old. Same as object->wait(old, order).
COOPSYNC_TBB_EXPORT void atomic_flag_notify_one (atomic_flag *object)
 Resumes one task suspended waiting on the atomic_flag, if there is any. Same as object.notify_one().
COOPSYNC_TBB_EXPORT void atomic_flag_notify_all (atomic_flag *object)
 Resumes all tasks suspended waiting on the atomic_flag. Same as object.notify_all().
template<typename R, typename... Args>
COOPSYNC_TBB_EXPORT void swap (packaged_task< R(Args...)> &lhs, packaged_task< R(Args...)> &rhs) noexcept
 Exchanges the states between two packaged_tasks.

Detailed Description

Main namespace of the library, containing all public APIs.

Function Documentation

◆ atomic_flag_clear()

COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_flag_clear ( atomic_flag * object)
noexcept

Atomically sets the state to clear. Same as object->clear().

Parameters
objectPointer to the atomic_flag to clear.

◆ atomic_flag_clear_explicit()

COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_flag_clear_explicit ( atomic_flag * object,
std::memory_order order )
noexcept

Atomically sets the state to clear. Same as object->clear(order).

Parameters
objectPointer to the atomic_flag to clear.
orderThe memory order to use for clearing the flag. Must not be std::memory_order_consume, std::memory_order_acquire or std::memory_order_acq_rel.

◆ atomic_flag_notify_all()

COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_flag_notify_all ( atomic_flag * object)

Resumes all tasks suspended waiting on the atomic_flag. Same as object.notify_all().

Parameters
objectPointer to the atomic_flag to notify on.

◆ atomic_flag_notify_one()

COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_flag_notify_one ( atomic_flag * object)

Resumes one task suspended waiting on the atomic_flag, if there is any. Same as object.notify_one().

Parameters
objectPointer to the atomic_flag to notify on.

◆ atomic_flag_test()

COOPSYNC_TBB_EXPORT bool coopsync_tbb::atomic_flag_test ( atomic_flag * object)
noexcept

Atomically reads the current state and returns it. Same as object->test().

Parameters
objectPointer to the atomic_flag to read.

◆ atomic_flag_test_and_set()

COOPSYNC_TBB_EXPORT bool coopsync_tbb::atomic_flag_test_and_set ( atomic_flag * object)
noexcept

Atomically sets the state to set and returns the previous state. Same as object->test_and_set().

Parameters
objectPointer to the atomic_flag to set.

◆ atomic_flag_test_and_set_explicit()

COOPSYNC_TBB_EXPORT bool coopsync_tbb::atomic_flag_test_and_set_explicit ( atomic_flag * object,
std::memory_order order )
noexcept

Atomically sets the state to set and returns the previous state. Same as object->test_and_set(order).

Parameters
objectPointer to the atomic_flag to set.
orderThe memory order to use for setting the flag.

◆ atomic_flag_test_explicit()

COOPSYNC_TBB_EXPORT bool coopsync_tbb::atomic_flag_test_explicit ( atomic_flag * object,
std::memory_order order )
noexcept

Atomically reads the current state and returns it. Same as object->test(order).

Parameters
objectPointer to the atomic_flag to read.
orderThe memory order to use for reading the flag. Must not be std::memory_order_release, std::memory_order_acq_rel.

◆ atomic_flag_wait()

COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_flag_wait ( atomic_flag * object,
bool old )

Suspends the calling task until the state is not equal to specified value. If the internal atomic the state is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the state is not equal to old. Same as object->wait(old).

Parameters
objectPointer to the atomic_flag to wait on.
oldThe value to compare the state to. The task will be suspended while the state is equal to old.
Note
Due to ABA problem, transitions from old to a different value and back to old may be missed.

◆ atomic_flag_wait_explicit()

COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_flag_wait_explicit ( atomic_flag * object,
bool old,
std::memory_order order )

Suspends the calling task until the state is not equal to specified value. If the internal atomic the state is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the state is not equal to old. Same as object->wait(old, order).

Parameters
objectPointer to the atomic_flag to wait on.
oldThe value to compare the state to. The task will be suspended while the state is equal to old.
orderThe memory order to use for loading the internal atomic value. Must not be std::memory_order_release or std::memory_order_acq_rel.
Note
Due to ABA problem, transitions from old to a different value and back to old may be missed.

◆ atomic_notify_all() [1/2]

template<typename T>
void coopsync_tbb::atomic_notify_all ( atomic_condition< T > * object)
inline

Resumes all tasks suspended waiting on the atomic_condition. Same as object->notify_all().

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to notify on.

◆ atomic_notify_all() [2/2]

template<typename T>
COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_notify_all ( atomic_condition< T > * object)
inline

Resumes all tasks suspended waiting on the atomic_condition. Same as object->notify_all().

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to notify on.

◆ atomic_notify_one() [1/2]

template<typename T>
void coopsync_tbb::atomic_notify_one ( atomic_condition< T > * object)
inline

Resumes one task suspended waiting on the atomic_condition, if there is any. Same as object->notify_one().

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to notify on.

◆ atomic_notify_one() [2/2]

template<typename T>
COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_notify_one ( atomic_condition< T > * object)
inline

Resumes one task suspended waiting on the atomic_condition, if there is any. Same as object->notify_one().

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to notify on.

◆ atomic_wait() [1/2]

template<typename T>
void coopsync_tbb::atomic_wait ( atomic_condition< T > * object,
typename atomic_condition< T >::value_type old )
inline

Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old).

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to wait on.
oldThe value to compare the internal atomic value to. The task will be suspended while the internal atomic value is equal to old.
Note
Due to ABA problem, transitions from old to a different value and back to old may be missed.
The comparison is done by bitwise comparison of the internal atomic value and old, not by operator==. The comparison may be affected by padding bytes.

◆ atomic_wait() [2/2]

template<typename T>
COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_wait ( atomic_condition< T > * object,
typename atomic_condition< T >::value_type old )
inline

Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old).

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to wait on.
oldThe value to compare the internal atomic value to. The task will be suspended while the internal atomic value is equal to old.
Note
Due to ABA problem, transitions from old to a different value and back to old may be missed.
The comparison is done by bitwise comparison of the internal atomic value and old, not by operator==. The comparison may be affected by padding bytes.

◆ atomic_wait_explicit() [1/2]

template<typename T>
void coopsync_tbb::atomic_wait_explicit ( atomic_condition< T > * object,
typename atomic_condition< T >::value_type old,
std::memory_order order )
inline

Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old, order).

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to wait on.
oldThe value to compare the internal atomic value to. The task will be suspended while the internal atomic value is equal to old.
orderThe memory order to use for loading the internal atomic value. Must not be std::memory_order_release or std::memory_order_acq_rel.
Note
Due to ABA problem, transitions from old to a different value and back to old may be missed.
The comparison is done by bitwise comparison of the internal atomic value and old, not by operator==. The comparison may be affected by padding bytes.

◆ atomic_wait_explicit() [2/2]

template<typename T>
COOPSYNC_TBB_EXPORT void coopsync_tbb::atomic_wait_explicit ( atomic_condition< T > * object,
typename atomic_condition< T >::value_type old,
std::memory_order order )
inline

Suspends the calling task until the internal atomic value of the atomic_condition is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic value is not equal to old. Same as object->wait(old, order).

Template Parameters
TThe type of the value contained in the atomic_condition.
Parameters
objectPointer to the atomic_condition to wait on.
oldThe value to compare the internal atomic value to. The task will be suspended while the internal atomic value is equal to old.
orderThe memory order to use for loading the internal atomic value. Must not be std::memory_order_release or std::memory_order_acq_rel.
Note
Due to ABA problem, transitions from old to a different value and back to old may be missed.
The comparison is done by bitwise comparison of the internal atomic value and old, not by operator==. The comparison may be affected by padding bytes.

◆ swap()

template<typename R, typename... Args>
COOPSYNC_TBB_EXPORT void coopsync_tbb::swap ( packaged_task< R(Args...)> & lhs,
packaged_task< R(Args...)> & rhs )
noexcept

Exchanges the states between two packaged_tasks.

Parameters
lhsThe first packaged_task to exchange state with.
rhsThe second packaged_task to exchange state with.