Go to the documentation of this file.00001 #ifndef GRASP_PLANNING_GRASPIT_THREADIMPL_H
00002 #define GRASP_PLANNING_GRASPIT_THREADIMPL_H
00003
00025 #define USE_BOOST_THREAD
00026
00027 #ifdef USE_BOOST_THREAD
00028
00029 #include <boost/thread.hpp>
00030 #define THREAD boost::thread
00031 #define THREAD_CONSTR boost::thread
00032 #define MUTEX boost::mutex
00033 #define RECURSIVE_MUTEX boost::recursive_mutex
00034 #define UNIQUE_LOCK boost::unique_lock<boost::mutex>
00035 #define UNIQUE_RECURSIVE_LOCK boost::unique_lock<boost::recursive_mutex>
00036 #define SLEEP(secs) { boost::this_thread::sleep(boost::posix_time::milliseconds(secs*1000)); }
00037
00038 #else // use c++11 std
00039
00040 #include <thread>
00041 #include <chrono>
00042 #define THREAD std::thread
00043 #define THREAD_CONSTR std::thread
00044 #define MUTEX std::mutex
00045 #define RECURSIVE_MUTEX std::recursive_mutex
00046 #define UNIQUE_LOCK std::unique_lock<std::mutex>
00047 #define UNIQUE_RECURSIVE_LOCK std::unique_lock<std::recursive_mutex>
00048 #define SLEEP(secs) \
00049 { \
00050 std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(std::floor(secs*1000))));\
00051 }
00052
00053 #endif
00054
00055 #endif // GRASP_PLANNING_GRASPIT_THREADIMPL_H