QTaskBuilder Class

template <typename Task, typename... Args> class QtConcurrent::QTaskBuilder

QTaskBuilder クラスはタスクのパラメータを調整するために使用されます。詳細...

ヘッダー #include <QTaskBuilder>
CMake: find_package(Qt6 REQUIRED COMPONENTS Concurrent)
target_link_libraries(mytarget PRIVATE Qt6::Concurrent)
qmake: QT += concurrent
以来:Qt 6.0

パブリック関数

QtConcurrent::QTaskBuilder<Task, Args...> &onThreadPool(QThreadPool &newThreadPool)
QFuture<QtConcurrent::InvokeResultType> spawn()
void spawn(QtConcurrent::FutureResult)
QtConcurrent::QTaskBuilder<Task, ExtraArgs...> withArguments(ExtraArgs &&... args)
QtConcurrent::QTaskBuilder<Task, Args...> &withPriority(int newPriority)

詳細説明

このクラスのオブジェクトを手動で作成することはできません。詳細と使用例についてはConcurrent Taskを参照してください。

メンバ関数ドキュメント

QtConcurrent::QTaskBuilder<Task, Args...> &QTaskBuilder::onThreadPool(QThreadPool &newThreadPool)

タスクが呼び出されるスレッド・プールnewThreadPool を設定する。

QFuture<QtConcurrent::InvokeResultType> QTaskBuilder::spawn()

別のスレッドでタスクを実行し、すぐにfutureオブジェクトを返す。これはノンブロッキング・コールです。タスクはすぐには始まらないかもしれません。

void QTaskBuilder::spawn(QtConcurrent::FutureResult)

タスクを別のスレッドで実行する。これはノンブロッキング・コールである。タスクはすぐには始まらないかもしれない。

template <typename... ExtraArgs> QtConcurrent::QTaskBuilder<Task, ExtraArgs...> QTaskBuilder::withArguments(ExtraArgs &&... args)

タスクが呼び出される引数args を設定する。以下の場合、コードは不正な形式(コンパイルエラーを引き起こす)となる:

  • この関数が複数回起動された。
  • 引数の数が0である。

QtConcurrent::QTaskBuilder<Task, Args...> &QTaskBuilder::withPriority(int newPriority)

タスクが起動される優先度newPriority を設定する。

関連する非メンバー

[alias] InvokeResultType

この型の簡略化された定義は次のようになる:

template <class Task, class ...Args>
using InvokeResultType = std::invoke_result_t<std::decay_t<Task>, std::decay_t<Args>...>;

実際の実装では、指定された引数でタスクを起動できるかどうかのコンパイル時チェックも行われる。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.