swift
Loading...
Searching...
No Matches
swift::misc::CPromise< T > Class Template Reference

A promise-based interface to QFuture, similar to std::promise for std::future. More...

#include <promise.h>

Public Member Functions

QFuture< T > future ()
 Return a future that can be used to access the result.
void abandon ()
 Mark the result as cancelled.
void setResult (const T &value)
 Set the result value that will be made available through the future.
template<typename U>
void setResult (QFuture< U > future)
 Set the result value from the given future. Will block if future is not ready.
template<typename U>
void chainResult (QFuture< U > future)
 When the given future is ready, use its result to set the result of this promise.
template<typename F>
void setResultFrom (F &&func)
 Invoke a functor and use its return value to set the result.

Detailed Description

template<typename T>
class swift::misc::CPromise< T >

A promise-based interface to QFuture, similar to std::promise for std::future.

Definition at line 86 of file promise.h.

Member Function Documentation

◆ abandon()

template<typename T>
void swift::misc::CPromise< T >::abandon ( )
inline

Mark the result as cancelled.

Definition at line 93 of file promise.h.

◆ chainResult()

template<typename T>
template<typename U>
void swift::misc::CPromise< T >::chainResult ( QFuture< U > future)
inline

When the given future is ready, use its result to set the result of this promise.

Definition at line 112 of file promise.h.

◆ future()

template<typename T>
QFuture< T > swift::misc::CPromise< T >::future ( )
inline

Return a future that can be used to access the result.

Definition at line 90 of file promise.h.

◆ setResult() [1/2]

template<typename T>
void swift::misc::CPromise< T >::setResult ( const T & value)
inline

Set the result value that will be made available through the future.

Definition at line 100 of file promise.h.

◆ setResult() [2/2]

template<typename T>
template<typename U>
void swift::misc::CPromise< T >::setResult ( QFuture< U > future)
inline

Set the result value from the given future. Will block if future is not ready.

Definition at line 104 of file promise.h.

◆ setResultFrom()

template<typename T>
template<typename F>
void swift::misc::CPromise< T >::setResultFrom ( F && func)
inline

Invoke a functor and use its return value to set the result.

Useful for uniform syntax in generic code where T could be void.

Definition at line 120 of file promise.h.


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