Sign in to follow this  
d000hg

Multi-Platform threading

Recommended Posts

d000hg    1199
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!

    Share this post


    Link to post
    Share on other sites
    d000hg    1199
    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?

    Share this post


    Link to post
    Share on other sites
    the_edd    2109
    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".

    Share this post


    Link to post
    Share on other sites
    cignox1    735
    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.

    Share this post


    Link to post
    Share on other sites
    jeroenb    282
    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]

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    Sign in to follow this