Search code examples
c++multithreadingqtqthreadqtcore

Can Qt synchronisation primitives be used with non-QThread threads?


I want to use, say, QSemaphore with boost threads or c++ 11 threads. Is that allowed?


Solution

  • I'm working on pqConsole, where multithreading plays an important role.

    Running a console for SWI-Prolog (multithreaded, implemented in C), the Qt GUI manages IO on behalf of user programs, executing in a background QThread, where the foreign language interface is instanced.

    Threads can also be initiated from C side, and they get a dedicated console (see interactor/0), where the IO again is rendered on Qt GUI.

    I'm using QMutex and QMutexLocker to syncronize (i.e. the simpler constructs), and AFAIK those are performing as expected.