Timer.hpp
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2009 Georgia Institute of Technology
00003 
00004   This library is free software: you can redistribute it and/or modify
00005   it under the terms of the GNU Lesser Public License as published by
00006   the Free Software Foundation, either version 3 of the License, or
00007   (at your option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU Lesser Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   and the GNU Lesser Public License along with Man.  If not, see
00016   <http://www.gnu.org/licenses/>.
00017 */
00018 #include <time.h>
00019 
00020 #ifndef Timer_hpp_DEFINED
00021 #define Timer_hpp_DEFINED
00022 namespace Timer {
00023     static const long long NANOSECONDS_PER_SECOND = 1000000000;
00024     static long long nanoTime(void) {
00025         timespec ts;
00026         clock_gettime(CLOCK_REALTIME, &ts);
00027         return ts.tv_sec*NANOSECONDS_PER_SECOND + ts.tv_nsec;
00028     }
00029 
00030     static void nanoSleepForTime(long long nsecs) {
00031         timespec ts;
00032         ts.tv_sec = nsecs / NANOSECONDS_PER_SECOND;
00033         ts.tv_nsec = ts.tv_sec % NANOSECONDS_PER_SECOND;
00034         nanosleep(&ts, NULL);
00035     }
00036 };
00037 #endif // Timer_hpp_DEFINED


tabletop_pushing
Author(s): Tucker Hermans
autogenerated on Wed Nov 27 2013 11:59:44