|
|
|
@ -23,48 +23,33 @@
|
|
|
|
|
#ifndef THREAD_H
|
|
|
|
|
#define THREAD_H
|
|
|
|
|
|
|
|
|
|
#include <boost/thread/future.hpp>
|
|
|
|
|
|
|
|
|
|
// hack to enable std::thread on mingw32 4.6
|
|
|
|
|
#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 {
|
|
|
|
|
using boost::thread;
|
|
|
|
|
using boost::future;
|
|
|
|
|
using boost::future_status;
|
|
|
|
|
using boost::promise;
|
|
|
|
|
|
|
|
|
|
using boost::mutex;
|
|
|
|
|
using boost::timed_mutex;
|
|
|
|
|
using boost::recursive_mutex;
|
|
|
|
|
using boost::recursive_timed_mutex;
|
|
|
|
|
|
|
|
|
|
using boost::lock_guard;
|
|
|
|
|
using boost::unique_lock;
|
|
|
|
|
|
|
|
|
|
using boost::condition_variable;
|
|
|
|
|
using boost::condition_variable_any;
|
|
|
|
|
|
|
|
|
|
template<typename R>
|
|
|
|
|
bool is_ready(std::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 {
|
|
|
|
|
template<typename R>
|
|
|
|
|
bool is_ready(std::future<R>& f)
|
|
|
|
|
{ return f.wait_for(chrono::seconds(0)) == future_status::ready; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|