C++ threads...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • barcaroller

    #1

    C++ threads...

    If this is not the right newsgroup for "C++ threads", please consider this
    message off-topic and ignore it.
    ---------------------------------------------
    I am writing a multi-threaded application in C++ (on Linux) and I'm
    wondering whether there are any recommendations on which C++ threads to use.
    The options I've found so far are:

    POSIX threads (C interface)
    C++ Threads (from SourceForge)
    Boost.Threads

    There must be others. Any recommendations ?


  • verdverm

    #2
    Re: C++ threads...

    On Apr 3, 6:33 pm, "barcarolle r" <barcarol...@mu sic.netwrote:
    If this is not the right newsgroup for "C++ threads", please consider this
    message off-topic and ignore it.
    ---------------------------------------------
    I am writing a multi-threaded application in C++ (on Linux) and I'm
    wondering whether there are any recommendations on which C++ threads to use.
    The options I've found so far are:
    >
    POSIX threads (C interface)
    C++ Threads (from SourceForge)
    Boost.Threads
    >
    There must be others. Any recommendations ?
    I am wondering the same thing also...
    I havd tried the posix threads with multiple socket clients making
    high rate requests and they start hanging (always in socket::recv()
    like waiting for incoming data? ), not all at the same time, and not
    always all of them.

    Not sure if its a thread memory problem or a problem with the TCP
    handshake
    The threads have access to a global static vector and make ~25 GET
    http requests per minute

    gcc 4.1 / kernel 2.6.20 / basically most recent stable releases

    Thoughts...?

    Comment

    • Ian Collins

      #3
      Re: C++ threads...

      barcaroller wrote:
      If this is not the right newsgroup for "C++ threads", please consider this
      message off-topic and ignore it.
      ---------------------------------------------
      I am writing a multi-threaded application in C++ (on Linux) and I'm
      wondering whether there are any recommendations on which C++ threads to use.
      The options I've found so far are:
      >
      POSIX threads (C interface)
      C++ Threads (from SourceForge)
      Boost.Threads
      >
      There must be others. Any recommendations ?
      >
      Search this group's archive for "threads", the topic has come up fairly
      often.

      --
      Ian Collins.

      Comment

      • Jacek Dziedzic

        #4
        Re: C++ threads...

        barcaroller wrote:
        If this is not the right newsgroup for "C++ threads", please consider this
        message off-topic and ignore it.
        ---------------------------------------------
        I am writing a multi-threaded application in C++ (on Linux) and I'm
        wondering whether there are any recommendations on which C++ threads to use.
        The options I've found so far are:
        >
        POSIX threads (C interface)
        C++ Threads (from SourceForge)
        Boost.Threads
        >
        There must be others. Any recommendations ?
        There's this thing called ZThread or ZThreads, but
        I have never tried it actually.

        HTH,
        - J.

        Comment

        • Michael Oswald

          #5
          Re: C++ threads...

          barcaroller wrote:
          POSIX threads (C interface)
          C++ Threads (from SourceForge)
          Boost.Threads
          >
          There must be others. Any recommendations ?

          Maybe a bit of overkill, but have a look at ACE (Adaptive Communication
          Environment) library, which has rather good thread classes and managers
          for thread pools an the like.


          Michael

          Comment

          • James Kanze

            #6
            Re: C++ threads...

            On Apr 4, 12:33 am, "barcarolle r" <barcarol...@mu sic.netwrote:
            I am writing a multi-threaded application in C++ (on Linux) and I'm
            wondering whether there are any recommendations on which C++ threads to use.
            The options I've found so far are:
            POSIX threads (C interface)
            C++ Threads (from SourceForge)
            Boost.Threads
            There must be others. Any recommendations ?
            I'd go with Boost. To date, I've not seen any with an interface
            really like, but Boost is low enough level that it's easy to
            wrap, it's probably the only one which has a good interface for
            the function in the other thread, and it's pretty portable, and
            looks rather robust. Of the other two I've experimented with,
            Posix threads don't work under Windows, of course, and ACE is
            buggy, and the idioms it uses are very out of date. When
            portability between systems isn't a concern, I'll use Posix
            directly. When portability to older compilers isn't a concern,
            I'll use Boost. (When both portabilities are a concern, you've
            got your work cut out for you:-).)

            --
            James Kanze (GABI Software) email:james.kan ze@gmail.com
            Conseils en informatique orientée objet/
            Beratung in objektorientier ter Datenverarbeitu ng
            9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

            Comment

            • Boris

              #7
              Re: C++ threads...

              On Wed, 04 Apr 2007 01:33:50 +0300, barcaroller <barcaroller@mu sic.net>
              wrote:
              If this is not the right newsgroup for "C++ threads", please consider
              this
              message off-topic and ignore it.
              ---------------------------------------------
              I am writing a multi-threaded application in C++ (on Linux) and I'm
              wondering whether there are any recommendations on which C++ threads to
              use.
              The options I've found so far are:
              >
              POSIX threads (C interface)
              C++ Threads (from SourceForge)
              Boost.Threads
              >
              There must be others. Any recommendations ?
              Depending on how much control you need over threads OpenMP might be an
              option, too. It's not C++ at all but uses #pragmas. The article at
              http://en.wikipedia.org/wiki/OpenMP should be enough for a quick overview.
              However I think you need at least GCC 4.1 or 4.2.

              Boris

              Comment

              • P.J. Plauger

                #8
                Re: C++ threads...

                "James Kanze" <james.kanze@gm ail.comwrote in message
                news:1175681605 .135383.185650@ p77g2000hsh.goo glegroups.com.. .

                On Apr 4, 12:33 am, "barcarolle r" <barcarol...@mu sic.netwrote:
                I am writing a multi-threaded application in C++ (on Linux) and I'm
                wondering whether there are any recommendations on which C++ threads to
                use.
                The options I've found so far are:
                POSIX threads (C interface)
                C++ Threads (from SourceForge)
                Boost.Threads
                There must be others. Any recommendations ?
                I'd go with Boost. To date, I've not seen any with an interface
                really like, but Boost is low enough level that it's easy to
                wrap, it's probably the only one which has a good interface for
                the function in the other thread, and it's pretty portable, and
                looks rather robust. Of the other two I've experimented with,
                Posix threads don't work under Windows, of course, and ACE is
                buggy, and the idioms it uses are very out of date. When
                portability between systems isn't a concern, I'll use Posix
                directly. When portability to older compilers isn't a concern,
                I'll use Boost. (When both portabilities are a concern, you've
                got your work cut out for you:-).)

                [pjp] The threading library we provide with our Compleat library
                is Boost compatible and works atop Windows, Posix, and Linux
                threads. It also has a C interface, unlike Boost threads.

                P.J. Plauger
                Dinkumware, Ltd.



                Comment

                • Fei Liu

                  #9
                  Re: C++ threads...

                  verdverm wrote:
                  On Apr 3, 6:33 pm, "barcarolle r" <barcarol...@mu sic.netwrote:
                  >If this is not the right newsgroup for "C++ threads", please consider this
                  >message off-topic and ignore it.
                  >---------------------------------------------
                  >I am writing a multi-threaded application in C++ (on Linux) and I'm
                  >wondering whether there are any recommendations on which C++ threads to use.
                  >The options I've found so far are:
                  >>
                  >POSIX threads (C interface)
                  >C++ Threads (from SourceForge)
                  >Boost.Thread s
                  >>
                  >There must be others. Any recommendations ?
                  >
                  I am wondering the same thing also...
                  I havd tried the posix threads with multiple socket clients making
                  high rate requests and they start hanging (always in socket::recv()
                  like waiting for incoming data? ), not all at the same time, and not
                  always all of them.
                  >
                  Not sure if its a thread memory problem or a problem with the TCP
                  handshake
                  The threads have access to a global static vector and make ~25 GET
                  http requests per minute
                  >
                  gcc 4.1 / kernel 2.6.20 / basically most recent stable releases
                  >
                  Thoughts...?
                  >
                  Most likely you have done something wrong. Apache2 can use pthread and I
                  never heard they had issue like you described. Read the apache2 source
                  code if you need inspiring examples of MT network programming.

                  Fei

                  Comment

                  • mlimber

                    #10
                    Re: C++ threads...

                    On Apr 4, 6:13 am, "James Kanze" <james.ka...@gm ail.comwrote:
                    On Apr 4, 12:33 am, "barcarolle r" <barcarol...@mu sic.netwrote:
                    >
                    I am writing a multi-threaded application in C++ (on Linux) and I'm
                    wondering whether there are any recommendations on which C++ threads to use.
                    The options I've found so far are:
                    POSIX threads (C interface)
                    C++ Threads (from SourceForge)
                    Boost.Threads
                    There must be others. Any recommendations ?
                    >
                    I'd go with Boost. To date, I've not seen any with an interface
                    really like, but Boost is low enough level that it's easy to
                    wrap, it's probably the only one which has a good interface for
                    the function in the other thread, and it's pretty portable, and
                    looks rather robust. Of the other two I've experimented with,
                    Posix threads don't work under Windows, of course, and ACE is
                    buggy, and the idioms it uses are very out of date. When
                    portability between systems isn't a concern, I'll use Posix
                    directly. When portability to older compilers isn't a concern,
                    I'll use Boost. (When both portabilities are a concern, you've
                    got your work cut out for you:-).)
                    I've used Boost.Threads with success, too, and I'd recommend it.
                    Here's an article in DDJ describing how to use them:



                    And here's a report on the on-going discussion of threads in the next
                    version of C++:



                    See also the Creator's brief mention of threads in the context of the
                    next version of C++:



                    Cheers! --M

                    Comment

                    • Gianni Mariani

                      #11
                      Re: C++ threads...

                      barcaroller wrote:
                      If this is not the right newsgroup for "C++ threads", please consider this
                      message off-topic and ignore it.
                      ---------------------------------------------
                      I am writing a multi-threaded application in C++ (on Linux) and I'm
                      wondering whether there are any recommendations on which C++ threads to use.
                      The options I've found so far are:
                      >
                      POSIX threads (C interface)
                      C++ Threads (from SourceForge)
                      Boost.Threads
                      >
                      There must be others. Any recommendations ?
                      >
                      >
                      I use Austria C++ ... Ok ok I wrote it too...

                      unreleased version is here - sourceforge has an earlier official release.

                      Comment

                      • slot

                        #12
                        Re: C++ threads...

                        On 4 Apr., 00:33, "barcarolle r" <barcarol...@mu sic.netwrote:
                        If this is not the right newsgroup for "C++ threads", please consider this
                        message off-topic and ignore it.
                        ---------------------------------------------
                        I am writing a multi-threaded application in C++ (on Linux) and I'm
                        wondering whether there are any recommendations on which C++ threads to use.
                        The options I've found so far are:
                        >
                        POSIX threads (C interface)
                        C++ Threads (from SourceForge)
                        Boost.Threads
                        >
                        There must be others. Any recommendations ?
                        Hello barcaroller. I havent tried the C++ threads from sourceForge,
                        but in my eyes you can choose either POSIX threads, if you like to get
                        your hands dirty, and want to know what the Boost/C++ Threads is doing
                        while running. This is only if you want to take a close study on the
                        many things that you can do with a thread. If you just want an easy
                        interface and dont care what is happining then choose the
                        Boost.Threads. It is good and safe.
                        I havent heard about any other implementations .

                        Comment

                        • Gianni Mariani

                          #13
                          Re: C++ threads...

                          barcaroller wrote:
                          If this is not the right newsgroup for "C++ threads", please consider this
                          message off-topic and ignore it.
                          ---------------------------------------------
                          I am writing a multi-threaded application in C++ (on Linux) and I'm
                          wondering whether there are any recommendations on which C++ threads to use.
                          The options I've found so far are:
                          >
                          POSIX threads (C interface)
                          C++ Threads (from SourceForge)
                          Boost.Threads
                          >
                          There must be others. Any recommendations ?

                          Oh - I forgot to mention CommonC++.

                          Comment

                          • =?UTF-8?B?SnVyYWogSXZhbsSNacSH?=

                            #14
                            Re: C++ threads...

                            James Kanze wrote:
                            ... and ACE is buggy, and the idioms it uses are very out of date...
                            I expect that ACE developers would be very grateful for any bug
                            report you submit. They would probably even implement any up-to-date
                            idiom, provided it makes sense. ACE is, after all, an actively
                            developed project.

                            Comment

                            Working...