|
QXmpp Version: 1.15.0
|
#include <QXmppTask.h>
Public Member Functions | |
| QXmppTask (QXmppTask &&t) | |
| Move constructor. | |
| QXmppTask (const QXmppTask &)=delete | |
| QXmppTask & | operator= (QXmppTask &&t) noexcept |
| Move assignment operator. | |
| QXmppTask & | operator= (const QXmppTask &)=delete |
| template<typename Continuation> | |
| auto | then (const QObject *context, Continuation continuation) -> QXmppTask< QXmpp::Private::InvokeContinuationResult< Continuation, T > > |
| QXmppTask< T > & | withContext (const QObject *c) |
| void | cancel () |
| bool | isFinished () const |
| bool | hasResult () const |
| QXmpp::Private::ConstRefOrVoid< T > | result () const |
| T | takeResult () |
| QFuture< T > | toFuture (const QObject *context) |
Friends | |
| class | QXmppPromise< T > |
Handle for an ongoing operation that finishes in the future.
Tasks are generated by QXmppPromise and can be handled using QXmppTask::then().
Unlike QFuture, this is not thread-safe!! This avoids the need to do mutex locking at every access though.
|
inline |
Cancels the task
If there is a waiting coroutine, it is cancelled immediately. Any continuation set in the future also won't be executed.
|
inlinenodiscard |
Returns whether the task is finished and the value has not been taken yet.
|
inlinenodiscard |
Whether the asynchronous operation is already finished.
This does not mean that the result is still stored, it might have been taken using takeResult() or handled using then().
|
inlinenodiscard |
The result of the operation.
|
inlinenodiscard |
Moves the result of the operation out of the task.
|
inline |
Registers a function that will be called with the result as parameter when the asynchronous operation finishes.
If the task is already finished when calling this (and still has a result), the function will be called immediately.
.then() can only be called once.
Example usage:
| context | QObject used for unregistering the handler function when the object is deleted. This way your lambda will never be executed after your object has been deleted. |
| continuation | A function accepting a result in the form of T &&. |
|
inlinenodiscard |
Converts the Task into a QFuture. Afterwards the QXmppTask object is invalid.
Sets a context object for co_await.
If this task is co_await'ed, the coroutine will only be resumed if the context object is still alive. This is very helpful for usage in member functions to assure that this still exists after an co_await statement.