QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
Loading...
Searching...
No Matches
QgsThreadingUtils Class Reference

Provides threading utilities for QGIS. More...

#include <qgsthreadingutils.h>

Static Public Member Functions

template<typename Func>
static bool runOnMainThread (const Func &func, QgsFeedback *feedback=nullptr)
 Guarantees that func is executed on the main thread.
static QString threadDescription (QThread *thread)
 Returns a descriptive identifier for a thread.

Detailed Description

Provides threading utilities for QGIS.

Since
QGIS 3.4

Definition at line 268 of file qgsthreadingutils.h.

Member Function Documentation

◆ runOnMainThread()

template<typename Func>
bool QgsThreadingUtils::runOnMainThread ( const Func & func,
QgsFeedback * feedback = nullptr )
inlinestatic

Guarantees that func is executed on the main thread.

If this is called from another thread, the other thread will be blocked until the function has been executed. This is useful to quickly access information from objects that live on the main thread and copying this information into worker threads. Avoid running expensive code inside func. If a feedback is provided, it will observe if the feedback is canceled. In case the feedback is canceled before the main thread started to run the function, it will return without executing the function.

Note
Only works with Qt >= 5.10, earlier versions will execute the code in the worker thread.
Since
QGIS 3.4

Definition at line 287 of file qgsthreadingutils.h.

◆ threadDescription()

QString QgsThreadingUtils::threadDescription ( QThread * thread)
static

Returns a descriptive identifier for a thread.

Since
QGIS 4.2

Definition at line 28 of file qgsthreadingutils.cpp.


The documentation for this class was generated from the following files: