|
| | PendingReplySource (QObject *owner) |
| | Creates a pending reply, optionally parented until settlement.
|
| |
| PendingReply * | reply () const |
| |
| bool | succeed (const T &value) const |
| | Attempts to settle the reply successfully with value.
|
| |
template<typename Object >
requires std::is_base_of_v<QObject, Object> && (std::is_same_v<T, QVariant> || std::is_convertible_v<Object*, T>) |
| bool | succeed (std::unique_ptr< Object > object) const |
| |
| bool | fail () const |
| | Attempts to settle the reply as a failure without requesting cancellation.
|
| |
| std::stop_token | stopToken () const |
| | Returns the operation's cooperative stop token.
|
| |
| void | setCancellationHandler (std::function< void()> handler) const |
| | Sets the cancellation handler for the producer's current stage.
|
| |
template<typename T>
class support::PendingReplySource< T >
Producer-side control for a PendingReply.
Copies share the same operation state. Construct the source and call reply(), succeed(), fail(), and setCancellationHandler() on the application thread. Workers may obtain and observe stopToken(), then queue settlement back to the application thread.
A non-null owner with application-thread affinity parents the reply while it is pending; nullptr leaves it unparented. If that owner destroys the pending reply, stop is requested, the current cancellation handler runs if one is installed, and reply() subsequently returns nullptr. Settlement removes any parent and marks the reply as JavaScript-owned. A JavaScript engine manages that lifetime only if the reply is exposed to it; a C++-only caller must delete the reply on the application thread.
- Template Parameters
-
| T | Type delivered on successful settlement. |
template<typename T >
template<typename Object >
requires std::is_base_of_v<QObject, Object> && (std::is_same_v<T, QVariant> || std::is_convertible_v<Object*, T>)
Transfers an independent QObject result. A QML caller can retain either the reply or the value. A native caller borrows it from the reply, or gives it another QObject parent before deleting the reply. Rejected deliveries are destroyed here.