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

Boost/std thread wrapping faultiness

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 0.10.0
    • 0.11.0
    • C++ - Library
    • None
    • OS: Windows 7 64bit
      Compile toolchain: Qt 5.6.0 with mingw4.9.2_32

    • Patch Available
    • Patch

    Description

      I want to use std::thread instead of boost::thread, so I turn on the macro USE_STD_THREAD manually in "windows/config.h":

      // use std::thread in MSVC11 (2012) or newer
      #if _MSC_VER >= 1700
      #define USE_STD_THREAD 1
      #else
      // otherwise use boost threads
      #define USE_BOOST_THREAD 1
      #endif
      
      // Cause mingw never define _MSC_VER,
      // USE_BOOST_THREAD is default set, not USE_STD_THREAD 
      // so here define it manually 
      #define USE_STD_THREAD 1
      #define USE_BOOST_THREAD 0
      

      Then I got a link error "undefined reference to this_thread::detail_::interruptible_wait() in BoostMonitor.o" when compiling my application using thrift static lib.

      Why still link to boost::thread lib when I set USE_STD_THREAD on? Strange! After hours later, I found that:
      1. StdMutex.cpp & StdMonitor.cpp are missing in My project, so I added then;
      2. BoostMutex.cpp & BoostMonitor.cpp and above 2 files didn't use USE_BOOST_THREAD/USE_STD_THREAD macro switch, so I fixed it:

      BoostMutex.cpp & BoostMonitor.cpp:

      #include <thrift/thrift-config.h>
      #if USE_BOOST_THREAD // added
      // ...
      #endif // added
      

      StdMutex.cpp & StdMonitor.cpp:

      #include <thrift/thrift-config.h>
      #if USE_STD_THREAD // added
      // ...
      #endif // added
      

      Then my application can be compiled successfully, without any boost binary library, just includes.

      Finally, I hope THRIFT library can be independent of boost, using C++11 features (smart-points/thread).

      Attachments

        Activity

          People

            jking3 James E. King III
            kimax Kimax Shieh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: