Hello Etienne!

On Fri, Jun 27, 2014 at 12:26 PM, Etienne Sandré-Chardonnal
<etienne.san...@m4x.org> wrote:
>> On Thu, 26 Jun 2014 22:32:14, Ruben Van Boxem wrote:
>> ...
>> You can use win32 threads!! Just the C++11 <thread>, <mutex> and <future>
>> stuff is build on top of the winpthreads library. Nothing is preventing
>> you from using only Win32 Threads.
>
> So you confirm that the stackoverflow post
> (http://stackoverflow.com/questions/17242516/mingw-w64-threads-posix-vs-win32)
> is wrong about the sentence:
>
> "So if you're using the the version of the runtime that was built with posix
> threads but decide to create threads in your own code with the win32 apis,
> you're likely to have problems at some point."
> ?

I can't give you a decisive confirmation, but I think that this is unlikely to
be true.  (Ruben and Kai should be able to offer greater certainty.)  It is
an implementation detail, so the (posix threads) implementation could be
doing something that would break win32 threads, but I would doubt it.

I would expect that you should be able to spawn and use pthreads, spawn
and use win32 threads (and spawn and use std::thread threads), and
everything should work fine.  The only place where I might expect trouble
would be if you tried to synchronize different brands of threads with one
another.

(Actually, I believe that all brands of threads are ultimately implemented as
win32 threads, so I bet you could synchronize all brands of threads on win32
synchronization structures.)

Also, the stackoverflow comment refers to the mingw wiki, even thought the
stackoverflow question asks about mingw-w64.  (mingw and mingw-w64 are
different projects.)  I doubt that the stackoverflow comment is true for either
mingw or mingw-w64, but it could, in principle, be true for mingw, but not for
mingw-w64.

> ...
> Well, it's not as easy... The code currently use a portable lib (Qt) for the
> threads but the question is about splitting a part of the app code for
> making a lib, intended to be used in a plugin sdk. And asking the customer
> to depend on external libraries is a sensitive topic...

It's not entirely clear to me what your problem is.  (In your original question
you asked whether you could detect pthreads vs. win32 threads with the
preprocessor at compile time.)

Why not use g++ / pthreads on linux, and mingw-w64's g++ / winpthreads
on windows and just use pthreads for your threading code?  I would expect
(expect, but don't know for certain) that the Qt's QThreads end up getting
mapped to native pthreads on linux and to win32 threads on windows.  But
unless you try to synchronize your own "user" pthreads with QThreads, I
think you should be able to use both pthreads and QThreads in the same
application both on linux and windows.

Could you sketch out the precise use case that you're concerned about?

> Thanks,
>
> Etienne


Happy Mixed-Thread Multithreaded Hacking!


K. Frank

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to