template<typename T>
class QXmppTask< 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.
- Since
- QXmpp 1.5
template<typename T >
void QXmppTask< T >::then |
( |
const QObject * |
context, |
|
|
Continuation |
continuation |
|
) |
| |
|
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.
If another function was previously registered using .then(), the old function will be replaced, and only the new one will be called.
Example usage:
void Manager::generate()
{
generateSomething().then(
this, [](QString &&
result) {
qDebug() <<
"Generating finished:" <<
result;
});
}
Definition: QXmppTask.h:62
const T & result() const
Definition: QXmppTask.h:162
- Parameters
-
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 && . |