AUI Framework
develop
Cross-platform base for C++ UI apps
|
Public Member Functions# | |
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) |
Signals and public fields# | |
bool | interrupted = false |
std::conditional_t< isVoid, bool, AOptional< Value > > | value |
AOptional< AInvocationTargetException > | exception |
ASpinlockMutex | mutex |
AConditionVariable | cv |
TaskCallback | task |
OnSuccessCallback | onSuccess |
std::function< void(const AException &exception)> | onError |
_< AAbstractThread > | thread |
bool | cancelled = false |
|
inlinenoexcept |
lock | lock of Inner::mutex mutex. |
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.
|
inline |
innerWeak | self weak_ptr |
ASpinlockMutex aui::impl::future::Future< Value >::Inner::mutex |
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.
std::conditional_t<isVoid, bool, AOptional<Value> > aui::impl::future::Future< Value >::Inner::value |
When isVoid = true, bool is a flag whether "void value" supplied or not