I want to write some code to be compatible with different boost versions, and want to use appropriate functions for the given boost versions. Right now I am trying,
#if BOOST_VERSION>105000
#define boost_sleep boost::this_thread::sleep_for
#define millisectime boost::chrono::milliseconds
#define timed_join try_join_for
#else
#define boost_sleep boost::this_thread::sleep
#define millisectime boost::posix_time::milliseconds
#endif
Which seem to compile fine. I am using it in the code with something like,
// Wait for no reason,
boost_sleep(millisectime(1000));
if( !(workerThread->timed_join(millisectime(1000)) )){
cout << "Not joined on time" << endl;
workerThread->detach();
}
Is there a better/standard way to do this? any suggestions to improve this?