|
| Inner (std::function< Value()> task) noexcept |
|
void | waitForTask () noexcept |
|
bool | isWaitNeeded () noexcept |
|
bool | hasResult () const noexcept |
|
bool | hasValue () const noexcept |
|
bool | setThread (_< AAbstractThread > thr) noexcept |
|
void | wait (const _weak< CancellationWrapper< Inner > > &innerWeak, ABitField< AFutureWait > flags=AFutureWait::DEFAULT) noexcept |
|
void | cancel () noexcept |
|
bool | tryExecute (const _weak< CancellationWrapper< Inner > > &innerWeak) |
| Executes the task stored in the future. Using weak_ptr to internal object in order to make possible Future cancellation by it's destruction.
|
|
void | reportInterrupted () noexcept |
|
void | reportException (std::exception_ptr causedBy=std::current_exception()) noexcept |
|
void | notifyOnSuccessCallback (std::unique_lock< decltype(mutex)> &lock) noexcept |
| Calls onSuccess callback.
|
|
template<typename F> |
void | invokeOnSuccessCallback (F &&f) |
|
template<typename Callback> |
void | addOnSuccessCallback (Callback &&callback) |
|
template<typename Callback> |
void | addOnErrorCallback (Callback &&callback) |
|
◆ notifyOnSuccessCallback()
template<typename Value = void>
Calls onSuccess callback.
- Parameters
-
lock is expected to be locked. Under the lock, callback is moved to local stack, lock is unlocked, and only then callback is called. This helps to avoid deadlocks (i.e. retreiving AFuture's value in onSuccess callback). lock is not locked again. If AFuture does not have value or onSuccess callback, the lock remains untouched.
◆ tryExecute()
template<typename Value = void>
Executes the task stored in the future. Using weak_ptr to internal object in order to make possible Future cancellation by it's destruction.
- Parameters
-
- Returns
- true, then task is successfully executed and supplied result.
◆ mutex
template<typename Value = void>
Spinlock mutex is used here because AFuture makes frequent calls to mutex and never locks for a long time. Durations are small enough so it is worth to just busy wait instead of making syscalls.
◆ value
template<typename Value = void>
When isVoid = true, bool is a flag whether "void value" supplied or not
The documentation for this struct was generated from the following file: