carb::tasking::Delegate< void(Args…)>

Defined in carb/tasking/Delegate.h

template<class ...Args>
class Delegate<void(Args...)> : public carb::delegate::detail::DelegateBase<::carb::tasking::MutexWrapper, detail::TaskingExec, void(Args...)>

Implements a task-aware, task-safe callback system that can have multiple subscribers.

A delegate is a weak-coupling callback system. Essentially, a system uses Delegate to have a callback that can be received by multiple subscribers.

Delegate has two ways to uniquely identify a bound callback: Bind() will output a Handle, or the caller can provide a key of any type with BindWithKey(). Either the Handle or the given key can be passed to Unbind() in order to remove a callback.

Delegate can call all bound callbacks with the Call() function. Recursive calling is allowed with caveats listed below.

Delegate is thread-safe and task-safe for all operations. Call() can occur simultaneously in multiple tasks or threads. An Unbind() will wait if the bound callback is currently executing in another thread or task.

Delegate can be destroyed from a binding (during Call()) as the internal state is not disposed of until all active calls have been completed. See ~Delegate().

Delegate does not hold any internal locks while calling bound callbacks. It is strongly recommended to avoid holding locks when invoking Delegate’s Call() function.

These tenets make up the basis of Carbonite’s Basic Callback Hygiene as described in the Coding Style Guidelines .


This task-aware delegate requires that the carb.tasking plugin is registered prior to instantiation.

Public Functions

Delegate() = default

Constructs an empty delegate.

inline Delegate(Delegate &&other)

Move constructor.


other – The Delegate to move from. This Delegate will be left in a valid but empty state.

inline Delegate &operator=(Delegate &&other)

Move-assign operator.


other – The Delegate to move-assign from. Will be swapped with *this.