Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1361

Optional replacement of pthread by boost::thread

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.8
    • 0.8
    • C++ - Library
    • Linux and Windows

    Description

      What it is:

      • an experimental alternative to using pthread in Thrift, by using boost::thread and boost::interprocess instead (--enable-boostthreads)
      • a way for thrift clients already depending on boost::thread to blend better with thrift
      • a solution to the Windows problem of having to link with ASF incompatible license of pthread_win32 (GPL), add more servers and transports to WIN32 (pooled, file, pipe...), and allow for a 64bits WIN32. See THRIFT-1031 for details.

      What it is NOT:

      • a replacement for the POSIX thread version of thrift: the POSIX pthread version has more features, and is probably more stable/mature. This feature is turned off by default by configure
      • a mature code: it has been really lightly tested, and is aimed primarily at the WIN32 platform

      New dependencies:

      • if --enable-boostthreads is provided, libthrift.so will link with shared libboost_thread.so (cannot work with libboost_thread.a AFAIK). This forces in effect Thrift to use a version of boost compiled with "./bjam link=shared"

      Bugs/Testing:

      • ./TestServer --server-type=thread-pool: PASS
      • ./TestServer --server-type=threaded: PASS
      • TFileTransportTest::test_destructor: FAILS: could not tell whether this is because I'm using a slow (virtual) machine (as pointed by the test comment)
      • Tested on Ubuntu/Windows, boost 1.44, libevent 2.0.14: however did not change the vc10 project files, because of potential conflict with on going THRIFT-1031
      • It is now possible to include more servers/transports to Win32, and also remove all pthread_win32 dependencies

      Related JIRA:

      Side notes:

      • there are minor corrections inside PosixThreadFactory for all platforms ("started" vs "starting"...), so that Win32 port also works with pthread_win32
      • TFileTransport has been enhanced to use the existing Mutex and Monitor abstractions
      • a minor fix in TSocket.cpp prevents verbose error, WIN32 only
      • minor enhancement by using WSAPoll if available, WIN32 only
      • on msvc10 and boost 1.44, there is a problem deep inside boost::interprocess: boost/interprocess/detail/move.hpp needs to be patched:
      index 31d108f..42aa227 100644
      --- a/boost/interprocess/detail/move.hpp
      +++ b/boost/interprocess/detail/move.hpp
      @@ -339,7 +339,7 @@ rvalue_reference move (input_reference);
       #else
       template <class T> inline
       typename remove_reference<T>::type&& move(T&& t)
      -{  return t;   }
      +{  return static_cast<typename remove_reference<T>::type &&>(t);   }
       #endif
      

      Please let me know of any questions, testing help appreciated (./configure --enable-boostthreads). This is an important change for our company, to get a Windows port of Thrift more on par with Linux features.

      Attachments

        1. THRIFT-1361.patch
          45 kB
          alexandre parenteau
        2. THRIFT-1361-configure.ac.patch
          0.9 kB
          alexandre parenteau
        3. THRIFT-1361-rev2.patch
          9 kB
          alexandre parenteau
        4. THRIFT-1361-rev3.patch
          9 kB
          alexandre parenteau

        Activity

          People

            aubonbeurre alexandre parenteau
            aubonbeurre alexandre parenteau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 48h
                48h
                Remaining:
                Remaining Estimate - 48h
                48h
                Logged:
                Time Spent - Not Specified
                Not Specified