Go to the documentation of this file.00001 #include "GaudiKernel/Sleep.h"
00002
00003 #if BOOST_VERSION < 15000
00004 #include "boost/thread/xtime.hpp"
00005 #endif
00006 #include "boost/thread/thread.hpp"
00007
00008 namespace Gaudi {
00009
00012 void Sleep(int sec){
00013 #if BOOST_VERSION >= 15000
00014 boost::this_thread::sleep_for(boost::chrono::seconds(sec));
00015 #else
00016 using namespace boost;
00017 xtime t;
00018 if ( xtime_get(&t,TIME_UTC) == TIME_UTC ) {
00019 t.sec += sec;
00020 thread::sleep(t);
00021 }
00022
00023 #endif
00024 }
00025
00028 void NanoSleep(long long nsec){
00029 #if BOOST_VERSION >= 15000
00030 boost::this_thread::sleep_for(boost::chrono::nanoseconds(nsec));
00031 #else
00032 using namespace boost;
00033 xtime t;
00034 if ( xtime_get(&t,TIME_UTC) == TIME_UTC ) {
00035 t.sec += nsec / 1000000000;
00036 t.nsec += nsec % 1000000000;
00037 thread::sleep(t);
00038 }
00039
00040 #endif
00041 }
00042
00043 }