Multi-Platform threading

Started by
7 comments, last by jeroenb 16 years, 5 months ago
I have some C++ threading libs to write and it would be really good if the code would work under Win32 and on Linux. I know that POSIX is the Linux way of doing things, and I have some experience with the Win32 threading API. So I could write wrapper classes and a bunch of #define blocks. But I wondered if someone already did it? So far I've uncovered:
  • pthreads for win32 - is it stable and is LGPL going to cause any problems?
  • Windows services for UNIX - looks unhelpful
  • Boost - am I right here, that Boost natively understands threading and would work equally well in Windows and Linux?
  • Thanks for any advice. I should point out, I am not able to release any code I write so if open source has restrictions please do tell me!
    Advertisement
    Boost threads should indeed work equally well on Linux and Windows. It follows the pthreads model reasonably closely.
    wxWidgets has multithreading support, it is as cross-platform as wxWidgets is. :)
    Check the other multithreading-thread, it contains a few multiplatform suggestions such as OpenMP and SDL.

    I guess boost will best fit your purpose though :)
    This is for some core multithreading functionality, which may be used in a variety of projects. So anything like wxWidgets or SDL is a bit of a big dependency. OpenMP is a great technology but not well-suited for writing a generic threading library.

    Boost sounds promising. Does anyone know how it actually creates threads on Windows? Does it have a dependency on the Win32 API in that case, or implement low-level code to talk directly to the CPU?
    Quote:Original post by d000hg
    Boost sounds promising. Does anyone know how it actually creates threads on Windows? Does it have a dependency on the Win32 API in that case, or implement low-level code to talk directly to the CPU?


    It uses the Win32 API. _beginthreadex, normally. CreateThread on Windows CE. I can't see how any threading library could avoid the kernel and "talk directly to the CPU".
    Old

    [Edited by - Robert Colton on March 1, 2008 9:04:52 AM]
    I would say to use boost::thread (or boost::threading ?). It reasonably easy to use and seem quite powerful. OpenMP is interesting, but as already said, perhaps not the right choice in this specific case.
    Hi, I am currently using the pthreads library for the developments of my cross-platform game framework. Till now I haven't had any (stability) problems with it on Windows. For me it works like a charm and easy in usage.

    EDIT:
    I do not know of any C++ library wrapping this package neatly. Though the LGPL is not going to limit you that much. It states that you may use your software in commercial applications without having to release your own wrapper sources(as far as I understand it).

    [Edited by - jeroenb on November 26, 2007 7:04:22 AM]

    Crafter 2D: the open source 2D game framework

    ?Github: https://github.com/crafter2d/crafter2d
    Twitter: [twitter]crafter_2d[/twitter]

    This topic is closed to new replies.

    Advertisement