RhythmGame 1.4.3
Loading...
Searching...
No Matches
Signals | Public Member Functions | Properties | Friends | List of all members
support::PendingReply Class Referencefinal

QML-facing handle for one asynchronous result. More...

#include <PendingReply.h>

Inheritance diagram for support::PendingReply:
Inheritance graph
[legend]
Collaboration diagram for support::PendingReply:
Collaboration graph
[legend]

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~PendingReply()

support::PendingReply::~PendingReply ( )
override
Precondition
Destroyed on the application thread.

Member Function Documentation

◆ cancel()

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.

Precondition
Called on the application thread.

◆ finished

void support::PendingReply::finished ( )
signal

Reports that a terminal result is available.

◆ isResultAvailable()

bool support::PendingReply::isResultAvailable ( ) const
Returns
Whether a success, failure, or cancellation has settled the reply.
Precondition
Called on the application thread.

◆ isSuccessful()

bool support::PendingReply::isSuccessful ( ) const
Returns
Whether the terminal result is successful. This is false while pending and after failure or cancellation.
Precondition
Called on the application thread.

◆ then()

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.

Parameters
successA callable receiving the successful value, or undefined.
failedA callable receiving no arguments, or undefined.
Precondition
Called on the application thread.

◆ value()

QVariant support::PendingReply::value ( ) const
Returns
The successful result, or an invalid QVariant while pending and after failure or cancellation.
Precondition
Called on the application thread.

Friends And Related Symbol Documentation

◆ PendingReplySource

template<typename T >
friend class PendingReplySource
friend

Property Documentation

◆ resultAvailable

bool support::PendingReply::resultAvailable = {}
read

◆ success

bool support::PendingReply::success
read

◆ value

QVariant support::PendingReply::value
read

The documentation for this class was generated from the following files: