16 #ifndef QGSTHREADINGUTILS_H 
   17 #define QGSTHREADINGUTILS_H 
   21 #include "qgis_core.h" 
   55     template <
typename Func>
 
   58 #if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) 
   61       if ( QThread::currentThread() == qApp->thread() )
 
   73           QSemaphore semaphoreMainThreadReady( 1 );
 
   78           QSemaphore semaphoreWorkerThreadReady( 1 );
 
   82           semaphoreMainThreadReady.acquire();
 
   83           semaphoreWorkerThreadReady.acquire();
 
   85           std::function<void()> waitFunc = [&semaphoreMainThreadReady, &semaphoreWorkerThreadReady]()
 
   90             semaphoreMainThreadReady.release();
 
   93             semaphoreWorkerThreadReady.acquire();
 
   96           QMetaObject::invokeMethod( qApp, waitFunc, Qt::QueuedConnection );
 
  100           while ( !semaphoreMainThreadReady.tryAcquire( 1, 100 ) )
 
  102             if ( feedback->isCanceled() )
 
  104               semaphoreWorkerThreadReady.release();
 
  114           semaphoreWorkerThreadReady.release();
 
  117         QMetaObject::invokeMethod( qApp, func, Qt::BlockingQueuedConnection );