clock.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __ZMQ_CLOCK_HPP_INCLUDED__
4 #define __ZMQ_CLOCK_HPP_INCLUDED__
5 
6 #include "macros.hpp"
7 #include "stdint.hpp"
8 
9 #if defined ZMQ_HAVE_OSX
10 // TODO this is not required in this file, but condition_variable.hpp includes
11 // clock.hpp to get these definitions
12 #ifndef CLOCK_REALTIME
13 #define CLOCK_REALTIME 0
14 #endif
15 #ifndef HAVE_CLOCK_GETTIME
16 #define HAVE_CLOCK_GETTIME
17 #endif
18 
19 #include <mach/clock.h>
20 #include <mach/mach.h>
21 #include <time.h>
22 #include <sys/time.h>
23 #endif
24 
25 namespace zmq
26 {
27 class clock_t
28 {
29  public:
30  clock_t ();
31 
32  // CPU's timestamp counter. Returns 0 if it's not available.
33  static uint64_t rdtsc ();
34 
35  // High precision timestamp.
36  static uint64_t now_us ();
37 
38  // Low precision timestamp. In tight loops generating it can be
39  // 10 to 100 times faster than the high precision timestamp.
40  uint64_t now_ms ();
41 
42  private:
43  // TSC timestamp of when last time measurement was made.
44  uint64_t _last_tsc;
45 
46  // Physical time corresponding to the TSC above (in milliseconds).
47  uint64_t _last_time;
48 
50 };
51 }
52 
53 #endif
zmq::clock_t::clock_t
clock_t()
Definition: clock.cpp:108
zmq::clock_t::_last_time
uint64_t _last_time
Definition: clock.hpp:47
zmq
Definition: zmq.hpp:229
macros.hpp
stdint.hpp
zmq::clock_t::now_us
static uint64_t now_us()
Definition: clock.cpp:118
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
zmq::clock_t::_last_tsc
uint64_t _last_tsc
Definition: clock.hpp:44
zmq::clock_t::rdtsc
static uint64_t rdtsc()
Definition: clock.cpp:213
zmq::clock_t
Definition: clock.hpp:27
zmq::clock_t::now_ms
uint64_t now_ms()
Definition: clock.cpp:181


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:48