QTaskBuilder Class
template <typename Task, typename Args> class QtConcurrent::QTaskBuilderThe QTaskBuilder class is used for adjusting task parameters. \since
6.0. More...
Header: | #include <QTaskBuilder> |
Public Functions
QTaskBuilder<Task, Args...> & | onThreadPool(QThreadPool &newThreadPool) |
QFuture<InvokeResultType> | spawn() |
void | spawn(FutureResult) |
QTaskBuilder<Task, ExtraArgs...> | withArguments(ExtraArgs &&... args) |
QTaskBuilder<Task, Args...> & | withPriority(int newPriority) |
Related Non-Members
Detailed Description
\inmodule
QtConcurrent
\ingroup
thread
It's not possible to create an object of this class manually. See Concurrent Task for more details and usage examples.
Member Function Documentation
QTaskBuilder<Task, Args...> &QTaskBuilder::onThreadPool(QThreadPool &newThreadPool)
Sets the thread pool newThreadPool that the task will be invoked on.
QFuture<InvokeResultType> QTaskBuilder::spawn()
Runs the task in a separate thread and returns a future object immediately. This is a non-blocking call. The task might not start immediately.
void QTaskBuilder::spawn(FutureResult)
Runs the task in a separate thread. This is a non-blocking call. The task might not start immediately.
template <typename ExtraArgs> QTaskBuilder<Task, ExtraArgs...> QTaskBuilder::withArguments(ExtraArgs &&... args)
Sets the arguments args the task will be invoked with. The code is ill-formed (causes compilation errors) if:
- This function is invoked more than once.
- The arguments count is zero.
QTaskBuilder<Task, Args...> &QTaskBuilder::withPriority(int newPriority)
Sets the priority newPriority that the task will be invoked with.
Related Non-Members
[alias]
InvokeResultType
The simplified definition of this type looks like this:
template <class Task, class ...Args> using InvokeResultType = std::invoke_result_t<std::decay_t<Task>, std::decay_t<Args>...>;
The real implementation also contains a compile-time check for whether the task can be invoked with the specified arguments or not.