1ZCLOCK(3)                         CZMQ Manual                        ZCLOCK(3)
2
3
4

NAME

6       zclock - millisecond clocks and delays
7

SYNOPSIS

9       //  This is a stable class, and may not change except for emergencies. It
10       //  is provided in stable builds.
11       //  Sleep for a number of milliseconds
12       CZMQ_EXPORT void
13           zclock_sleep (int msecs);
14
15       //  Return current system clock as milliseconds. Note that this clock can
16       //  jump backwards (if the system clock is changed) so is unsafe to use for
17       //  timers and time offsets. Use zclock_mono for that instead.
18       CZMQ_EXPORT int64_t
19           zclock_time (void);
20
21       //  Return current monotonic clock in milliseconds. Use this when you compute
22       //  time offsets. The monotonic clock is not affected by system changes and
23       //  so will never be reset backwards, unlike a system clock.
24       CZMQ_EXPORT int64_t
25           zclock_mono (void);
26
27       //  Return current monotonic clock in microseconds. Use this when you compute
28       //  time offsets. The monotonic clock is not affected by system changes and
29       //  so will never be reset backwards, unlike a system clock.
30       CZMQ_EXPORT int64_t
31           zclock_usecs (void);
32
33       //  Return formatted date/time as fresh string. Free using zstr_free().
34       //  Caller owns return value and must destroy it when done.
35       CZMQ_EXPORT char *
36           zclock_timestr (void);
37
38       //  Self test of this class.
39       CZMQ_EXPORT void
40           zclock_test (bool verbose);
41
42       Please add '@interface' section in './../src/zclock.c'.
43

DESCRIPTION

45       The zclock class provides essential sleep and system time functions,
46       used to slow down threads for testing, and calculate timers for
47       polling. Wraps the non-portable system calls in a simple portable API.
48
49       The Win32 Sleep() call defaults to 16ms resolution unless the system
50       timer resolution is increased with a call to timeBeginPeriod()
51       permitting 1ms granularity.
52

EXAMPLE

54       From zclock_test method.
55
56           int64_t start = zclock_time ();
57           zclock_sleep (10);
58           assert ((zclock_time () - start) >= 10);
59           start = zclock_mono ();
60           int64_t usecs = zclock_usecs ();
61           zclock_sleep (10);
62           assert ((zclock_mono () - start) >= 10);
63           assert ((zclock_usecs () - usecs) >= 10000);
64           char *timestr = zclock_timestr ();
65           if (verbose)
66               puts (timestr);
67           free (timestr);
68
69

AUTHORS

71       The czmq manual was written by the authors in the AUTHORS file.
72

RESOURCES

74       Main web site:
75
76       Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
77
79       Copyright (c) the Contributors as noted in the AUTHORS file. This file
80       is part of CZMQ, the high-level C binding for 0MQ:
81       http://czmq.zeromq.org. This Source Code Form is subject to the terms
82       of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
83       distributed with this file, You can obtain one at
84       http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
85       distribution.
86

NOTES

88        1. zeromq-dev@lists.zeromq.org
89           mailto:zeromq-dev@lists.zeromq.org
90
91
92
93CZMQ 4.0.2                        12/31/2016                         ZCLOCK(3)
Impressum