|
RhythmGame 1.4.3
|
QML-facing handle for one asynchronous result. More...
#include <PendingReply.h>


Signals | |
| void | finished () |
| Reports that a terminal result is available. | |
Public Member Functions | |
| ~PendingReply () override | |
| bool | isResultAvailable () const |
| bool | isSuccessful () const |
| QVariant | value () const |
| Q_INVOKABLE void | then (const QJSValue &success, const QJSValue &failed=QJSValue()) |
| Registers callbacks for the terminal result. | |
| Q_INVOKABLE void | cancel () |
| Settles the reply as a cancelled terminal failure. | |
Properties | |
| bool | resultAvailable = {} |
| bool | success |
| QVariant | value |
Friends | |
| template<typename T > | |
| class | PendingReplySource |
QML-facing handle for one asynchronous result.
The QML component that starts an operation owns its cancellation: it retains the returned reply and calls cancel() when that operation is no longer needed. PendingReplySource<T>::succeed(), PendingReplySource<T>::fail(), and cancel() compete to settle the reply; the first terminal result wins.
All access to a PendingReply, including property reads and destruction, is restricted to the application thread. Settlement, signal emission, and callback invocation also occur there.
A non-null owner with application-thread affinity supplied to PendingReplySource is the reply's QObject parent while it is pending; passing nullptr leaves it unparented. Settlement removes any parent and marks the reply as JavaScript-owned. A JavaScript engine can manage that lifetime only if the reply is exposed to it; a C++-only caller must delete the reply on the application thread.
Destroying the reply while it is still pending, including through teardown of such an owner, requests stop and then invokes the current cancellation handler if one is installed.
|
override |
| void support::PendingReply::cancel | ( | ) |
Settles the reply as a cancelled terminal failure.
When cancellation wins, it requests stop. The cancellation handler captured at settlement is invoked only if synchronous stop callbacks leave the reply alive. Calling cancel() again, or after another terminal result has won, has no effect.
|
signal |
Reports that a terminal result is available.
| bool support::PendingReply::isResultAvailable | ( | ) | const |
| bool support::PendingReply::isSuccessful | ( | ) | const |
| void support::PendingReply::then | ( | const QJSValue & | success, |
| const QJSValue & | failed = QJSValue() |
||
| ) |
Registers callbacks for the terminal result.
A valid call while pending replaces both callbacks registered by an earlier call. A valid call after settlement invokes the callback matching the result synchronously. This function and the callbacks run on the application thread.
| success | A callable receiving the successful value, or undefined. |
| failed | A callable receiving no arguments, or undefined. |
| QVariant support::PendingReply::value | ( | ) | const |
|
friend |
|
read |
|
read |
|
read |