Pergunta

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

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top