이 페이지에서

QtTaskTree::Do Class

class QtTaskTree::Do

For 및 When 구문과 함께 사용되는 본문 요소입니다. 더 보기...

Header: #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 의 경우에는 바람직하지 않을 수 있습니다.

ForWhen참조하세요 .

멤버 함수 문서

[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.