libzmq master
The Intelligent Transport Layer

clock.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2010-2011 250bpm s.r.o.
00003     Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
00004 
00005     This file is part of 0MQ.
00006 
00007     0MQ is free software; you can redistribute it and/or modify it under
00008     the terms of the GNU Lesser General Public License as published by
00009     the Free Software Foundation; either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     0MQ is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef __ZMQ_CLOCK_HPP_INCLUDED__
00022 #define __ZMQ_CLOCK_HPP_INCLUDED__
00023 
00024 #include "stdint.hpp"
00025 
00026 namespace zmq
00027 {
00028 
00029     class clock_t
00030     {
00031     public:
00032 
00033         clock_t ();
00034         ~clock_t ();
00035 
00036         //  CPU's timestamp counter. Returns 0 if it's not available.
00037         static uint64_t rdtsc ();
00038 
00039         //  High precision timestamp.
00040         static uint64_t now_us ();
00041 
00042         //  Low precision timestamp. In tight loops generating it can be
00043         //  10 to 100 times faster than the high precision timestamp.
00044         uint64_t now_ms ();
00045 
00046     private:
00047 
00048         //  TSC timestamp of when last time measurement was made.
00049         uint64_t last_tsc;
00050 
00051         //  Physical time corresponding to the TSC above (in milliseconds).
00052         uint64_t last_time;
00053 
00054         clock_t (const clock_t&);
00055         const clock_t &operator = (const clock_t&);
00056     };
00057 
00058 }
00059 
00060 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines