QtTaskTree::Do Class
class QtTaskTree::DoFor構文やWhen構文で使われるボディ要素。詳細...
| ヘッダ | #include <qtasktree.h> |
| CMakeの | find_package(Qt6 REQUIRED COMPONENTS TaskTree)target_link_libraries(mytarget PRIVATE Qt6::TaskTree) |
| qmake: | QT += tasktree |
| 以来: | Qt 6.11 |
注意:このクラスの関数はすべてリエントラントです。
パブリック関数
| Do(const QtTaskTree::GroupItems &children) | |
| Do(std::initializer_list<QtTaskTree::GroupItem> children) |
詳細説明
For の各反復、またはWhen のバリアが進んだ後に実行されるタスクのリストを保持するボディ要素。
For (RepeatIterator(5)) >> Do { task1, task2 };
Forループの場合、Do本体は複数回実行される。onGroupSetup() やonGroupDone() のハンドラがDoのコンストラクタに渡された子プロセスの一部である場合、それらはループ全体が始まる前とループ全体が終わった後に一度だけ実行される:
const RepeatIterator iterator(3); const auto onSetup = [] { qDebug() << "Setup"; }; const auto onSync = [iterator] { qDebug() << "Current iteration:" << iterator->iteration(); }; const auto onDone = [] { qDebug() << "Done"; }; const Group recipe = For (iterator) >> Do { onGroupSetup(onSetup), QSyncTask(onSync), onDone(onDone) };
上記のレシピは、実行されると出力される:
Setup Current iteration: 0 Current iteration: 1 Current iteration: 2 Done
各反復でグループハンドラを呼び出す場合は、Do本体をGroup で囲んでください:
const Group recipe = For (iterator) >> Do { Group { onGroupSetup(onSetup), QSyncTask(onSync), onDone(onDone) } };
後者のレシピが実行されると、次のように出力される:
Setup Current iteration: 0 Done Setup Current iteration: 1 Done Setup Current iteration: 2 Done
ボディの直接の子としてStorage 。ストレージ構造は、ループ全体が始まる前に一度だけインスタンス化され、ループ全体が終わった直後に破棄される。各反復ごとにStorage の別々のインスタンスを持つことを意図している場合は、Do本体を余分なGroup で囲む。
For ループのDo本体にparallel 要素を置くと、すべての反復が並列に開始されるので注意が必要である。これは、特にForeverIterator の場合、望ましくないかもしれない。
メンバ関数ドキュメント
[explicit] Do::Do(const QtTaskTree::GroupItems &children)
For の各反復時、またはWhen のバリアが進んだ後に実行される、children を持つ Do 本体を構築する。
[explicit] Do::Do(std::initializer_list<QtTaskTree::GroupItem> children)
イニシャライザーリストとして渡されたchildren で Do 本体を構築する。
これはオーバーロードされた関数です。
© 2026 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.