Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_corelib_concurrent_qthreadpool.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#
include
<
QThreadPool
>
5
#
include
<
QRunnable
>
6
#
include
<
QDebug
>
7
8
//! [0]
9
class
HelloWorldTask
:
public
QRunnable
10
{
11
void
run
()
override
12
{
13
qDebug() <<
"Hello world from thread"
<< QThread::currentThread();
14
}
15
};
16
17
int
main
()
18
{
19
//...
20
HelloWorldTask
*hello =
new
HelloWorldTask
();
21
// QThreadPool takes ownership and deletes 'hello' automatically
22
QThreadPool::globalInstance()->start(hello);
23
//...
24
}
25
//! [0]
HelloWorldTask
[0]
Definition
src_corelib_concurrent_qthreadpool.cpp:10
HelloWorldTask::run
void run() override
Implement this pure virtual function in your subclass.
Definition
src_corelib_concurrent_qthreadpool.cpp:11
main
int main()
[open]
Definition
doc_src_objecttrees.cpp:7
qtbase
src
corelib
doc
snippets
code
src_corelib_concurrent_qthreadpool.cpp
Generated on
for Qt by
1.14.0