All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sleep.cpp
Go to the documentation of this file.
1 #include "GaudiKernel/Sleep.h"
2 
3 #include "boost/version.hpp"
4 
5 #if BOOST_VERSION < 105000
6 #include "boost/thread/xtime.hpp"
7 #endif
8 #include "boost/thread/thread.hpp"
9 
10 namespace Gaudi {
11 
14  void Sleep(int sec){
15 #if BOOST_VERSION >= 105000
16  boost::this_thread::sleep_for(boost::chrono::seconds(sec));
17 #else
18  using namespace boost;
19  xtime t;
20  if ( xtime_get(&t,TIME_UTC) == TIME_UTC ) {
21  t.sec += sec;
22  thread::sleep(t);
23  }
24  // TODO: (MCl) do something if cannot get the time.
25 #endif
26  }
27 
30  void NanoSleep(long long nsec){
31 #if BOOST_VERSION >= 105000
32  boost::this_thread::sleep_for(boost::chrono::nanoseconds(nsec));
33 #else
34  using namespace boost;
35  xtime t;
36  if ( xtime_get(&t,TIME_UTC) == TIME_UTC ) {
37  t.sec += nsec / 1000000000;
38  t.nsec += nsec % 1000000000;
39  thread::sleep(t);
40  }
41  // TODO: (MCl) do something if cannot get the time.
42 #endif
43  }
44 
45 }
GAUDI_API void NanoSleep(long long nsec)
Small variation on the sleep function for nanoseconds sleep.
Definition: Sleep.cpp:30
GAUDI_API void Sleep(int sec)
Simple sleep function.
Definition: Sleep.cpp:14
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:14