QRunnable Class
QRunnable 클래스는 모든 실행 가능한 객체의 기본 클래스입니다. 더 보기...
헤더: | #include <QRunnable> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
- 상속된 멤버를 포함한 모든 멤버 목록
- QRunnable은 스레딩 클래스의 일부입니다.
공용 함수
QRunnable() | |
virtual | ~QRunnable() |
bool | autoDelete() const |
virtual void | run() = 0 |
void | setAutoDelete(bool autoDelete) |
정적 공용 멤버
QRunnable * | create(Callable &&callableToRun) |
상세 설명
QRunnable 클래스는 실행해야 하는 작업 또는 코드를 나타내는 인터페이스로, run() 함수의 재구현으로 표현됩니다.
QThreadPool 을 사용하여 별도의 스레드에서 코드를 실행할 수 있습니다. QThreadPool 은 autoDelete()가 true
(기본값)을 반환하면 QRunnable을 자동으로 삭제합니다. 자동 삭제 플래그를 변경하려면 setAutoDelete()를 사용합니다.
QThreadPool run () 함수 내에서 QThreadPool::tryStart(이)를 호출하여 동일한 QRunnable을 두 번 이상 실행하는 것을 지원합니다. autoDelete 가 활성화된 경우 마지막 스레드가 실행 함수를 종료할 때 QRunnable이 삭제됩니다. autoDelete 이 활성화된 상태에서 동일한 QRunnable로 QThreadPool::start()을 여러 번 호출하면 경쟁 조건이 발생하므로 권장되지 않습니다.
QThreadPool 를참조하세요 .
멤버 함수 문서
[constexpr noexcept]
QRunnable::QRunnable()
QRunnable을 생성합니다. 자동 삭제는 기본적으로 활성화되어 있습니다.
autoDelete() 및 setAutoDelete()도 참조하세요 .
[virtual noexcept]
QRunnable::~QRunnable()
QRunnable 가상 소멸자.
bool QRunnable::autoDelete() const
자동 삭제가 활성화된 경우 true
, 그렇지 않으면 false를 반환합니다.
자동 삭제가 활성화되면 run() 호출 후 QThreadPool 이 런처블을 자동으로 삭제하고, 그렇지 않으면 소유권은 애플리케이션 프로그래머에게 유지됩니다.
setAutoDelete() 및 QThreadPool도 참조하세요 .
[static]
template <typename Callable, QRunnable::if_callable<Callable> = true> QRunnable *QRunnable::create(Callable &&callableToRun)
run()에서 callableToRun 을 호출하는 QRunnable 을 만듭니다.
자동 삭제는 기본적으로 활성화되어 있습니다.
참고: 이 함수는 Callable
이 인수가 0으로 호출할 수 있는 함수 또는 함수 객체인 경우에만 과부하 해결에 참여합니다.
참고: 6.6 이전 Qt 버전에서는 이 메서드가 복사 가능한 함수만 사용했습니다.
run() 및 autoDelete()도 참조하세요 .
[pure virtual]
void QRunnable::run()
서브클래스에서 이 순수 가상 함수를 구현하세요.
void QRunnable::setAutoDelete(bool autoDelete)
autoDelete 이 참이면 자동 삭제를 활성화하고, 그렇지 않으면 자동 삭제가 비활성화됩니다.
자동 삭제가 활성화되면 run() 호출 후 QThreadPool 이 런처블을 자동으로 삭제하고, 그렇지 않으면 소유권은 애플리케이션 프로그래머에게 유지됩니다.
QThreadPool::start()를 호출하기 전에 이 플래그를 설정해야 합니다. QThreadPool::start () 이후에 이 함수를 호출하면 정의되지 않은 동작이 발생합니다.
autoDelete() 및 QThreadPool 을참조하세요 .
© 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.