Use boost::thread instead of std::thread

This commit is contained in:
Eduardo Bart
2013-03-04 23:05:22 -03:00
parent 5396ea6231
commit 71b5c5f2e4
8 changed files with 49 additions and 23 deletions

View File

@@ -24,14 +24,15 @@
#define THREAD_H
// hack to enable std::thread on mingw32 4.6
#if !defined(_GLIBCXX_HAS_GTHREADS) && defined(__GNUG__)
#if 1
//#if !defined(_GLIBCXX_HAS_GTHREADS) && defined(__GNUG__)
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/future.hpp>
#include <boost/thread/condition_variable.hpp>
namespace std {
namespace stdext {
using boost::thread;
using boost::future;
using boost::future_status;
@@ -49,21 +50,43 @@ namespace std {
using boost::condition_variable_any;
template<typename R>
bool is_ready(std::future<R>& f)
bool is_ready(stdext::future<R>& f)
{ return f.wait_for(boost::chrono::seconds(0)) == future_status::ready; }
}
#else
#include <thread>
#include <condition_variable>
#include <mutex>
#include <future>
namespace std {
namespace stdext {
template<typename R>
bool is_ready(std::future<R>& f)
{ return f.wait_for(chrono::seconds(0)) == future_status::ready; }
};
namespace stdext {
using std::thread;
using std::future;
using std::future_status;
using std::promise;
using std::mutex;
using std::timed_mutex;
using std::recursive_mutex;
using std::recursive_timed_mutex;
using std::lock_guard;
using std::unique_lock;
using std::condition_variable;
using std::condition_variable_any;
template<typename R>
bool is_ready(std::future<R>& f)
{ return f.wait_for(boost::chrono::seconds(0)) == future_status::ready; }
}
#endif