lsnes/include/library/threadtypes.hpp

46 lines
1.2 KiB
C++
Raw Normal View History

2012-11-13 22:01:12 +02:00
#ifndef _library_threadtypes__hpp__included__
#define _library_threadtypes__hpp__included__
#include <cstdint>
#ifdef NATIVE_THREADS
#include <thread>
#include <condition_variable>
#include <mutex>
typedef std::thread thread_class;
typedef std::condition_variable cv_class;
typedef std::mutex mutex_class;
typedef std::unique_lock<std::mutex> umutex_class;
typedef std::chrono::microseconds microsec_class;
2013-01-21 12:04:09 +02:00
typedef std::thread::id threadid_class;
typedef std::thread thread_class;
inline void cv_timed_wait(cv_class& c, umutex_class& m, const microsec_class& t)
{
c.wait_for(m, t);
}
2013-01-21 12:04:09 +02:00
inline threadid_class this_thread_id()
{
return std::this_thread::get_id();
}
2012-11-13 22:01:12 +02:00
#else
#include <boost/thread.hpp>
#include <boost/thread/locks.hpp>
typedef boost::thread thread_class;
typedef boost::condition_variable cv_class;
typedef boost::mutex mutex_class;
typedef boost::unique_lock<boost::mutex> umutex_class;
typedef boost::posix_time::microseconds microsec_class;
2013-01-21 12:04:09 +02:00
typedef boost::thread::id threadid_class;
typedef boost::thread thread_class;
inline void cv_timed_wait(cv_class& c, umutex_class& m, const microsec_class& t)
{
c.timed_wait(m, t);
}
2013-01-21 12:04:09 +02:00
inline threadid_class this_thread_id()
{
return boost::this_thread::get_id();
}
2012-11-13 22:01:12 +02:00
#endif
#endif