private.h

Go to the documentation of this file.
00001 
00015 #ifndef _DLR_THREAD_PRIVATE_H_
00016 #define _DLR_THREAD_PRIVATE_H_
00017 
00018 #include <dlrCommon/exception.h>
00019 
00020 namespace dlr {
00021 
00022   namespace thread {
00023 
00024     // This private function returns by reference boost::xtime
00025     // instance that represents a time that is timeout seconds in the
00026     // future.
00027     inline bool
00028     getXTime(double timeout, boost::xtime& xtimeout)
00029     {
00030       if(boost::xtime_get(&xtimeout, boost::TIME_UTC) == 0) {
00031         // Couldn't get the current time.
00032         return false;
00033       }
00034       long int seconds = static_cast<long int>(timeout);
00035       long int nanoSeconds = static_cast<long int>(
00036         (timeout - seconds) * 1000000000);
00037       xtimeout.sec += seconds;
00038       xtimeout.nsec += nanoSeconds;
00039       while(xtimeout.nsec >= 1000000000) {
00040         ++(xtimeout.sec);
00041         xtimeout.nsec -= 1000000000;
00042       }
00043       while(xtimeout.nsec < 0) {
00044         --(xtimeout.sec);
00045         xtimeout.nsec += 1000000000;
00046       }
00047       return true;
00048     }
00049 
00050   } // namespace thread
00051 
00052 } // namespace dlr
00053 
00054 #endif /* #ifndef _DLR_THREAD_CLIENTID_H_ */

Generated on Mon Jul 9 20:34:03 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2