Qt
6.x
The Qt SDK
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
5
class
HelloWorldTask
:
public
QRunnable
6
{
7
void
run
()
override
8
{
9
qDebug
() <<
"Hello world from thread"
<<
QThread::currentThread
();
10
}
11
};
12
13
HelloWorldTask
*
hello
=
new
HelloWorldTask
();
14
// QThreadPool takes ownership and deletes 'hello' automatically
15
QThreadPool::globalInstance
()->
start
(
hello
);
HelloWorldTask
[0]
Definition
src_corelib_concurrent_qthreadpool.cpp:6
HelloWorldTask::run
void run() override
Implement this pure virtual function in your subclass.
Definition
src_corelib_concurrent_qthreadpool.cpp:7
QRunnable
\inmodule QtCore
Definition
qrunnable.h:18
QThreadPool::start
void start(QRunnable *runnable, int priority=0)
Reserves a thread and uses it to run runnable, unless this thread will make the current thread count ...
Definition
qthreadpool.cpp:507
QThreadPool::globalInstance
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
Definition
qthreadpool.cpp:466
QThread::currentThread
static QThread * currentThread()
Definition
qthread.cpp:966
qDebug
#define qDebug
[1]
Definition
qlogging.h:160
hello
HelloWorldTask * hello
Definition
src_corelib_concurrent_qthreadpool.cpp:13
qtbase
src
corelib
doc
snippets
code
src_corelib_concurrent_qthreadpool.cpp
Generated by
1.9.7