Violet Giraffe
Violet Giraffe

Reputation: 33605

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?

Upvotes: 1

Views: 218

Answers (2)

CapelliC
CapelliC

Reputation: 60034

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.

Upvotes: 2

László Papp
László Papp

Reputation: 53215

Theoretically, yes, you can.

Note, you could also just use the boost semaphore available with that scenario. Also, QSemaphore currently does not use the pthread interface underneath, but some custom solution. There were discussions to refactor that later for utilizing the pthread features more.

Upvotes: 0

Related Questions