ZTIMERSET(3)
π ZTIMERSET(3) π
okay bestie, welcome to the CZMQ Manual page for ztimerset β the timer set class, and honestly? she's giving "draft era, still iconic" β¨
π NAME π
ztimerset β class for timer set π
πΈ SYNOPSIS πΈ
so like, before you even look at the functions β read this part, it's lowkey important:
// This is a draft class, and may change without notice. It is disabled in
// stable builds by default. If you use this in applications, please ask
// for it to be pushed to stable state. Use --enable-drafts to enable.
#ifdef CZMQ_BUILD_DRAFT_API
// Callback function for timer event.
typedef void (ztimerset_fn) (
int timer_id, void *arg);
// *** Draft method, for development use, may change without warning ***
// Create new timer set.
CZMQ_EXPORT ztimerset_t *
ztimerset_new (void);
// *** Draft method, for development use, may change without warning ***
// Destroy a timer set
CZMQ_EXPORT void
ztimerset_destroy (ztimerset_t **self_p);
// *** Draft method, for development use, may change without warning ***
// Add a timer to the set. Returns timer id if OK, -1 on failure.
CZMQ_EXPORT int
ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg);
// *** Draft method, for development use, may change without warning ***
// Cancel a timer. Returns 0 if OK, -1 on failure.
CZMQ_EXPORT int
ztimerset_cancel (ztimerset_t *self, int timer_id);
// *** Draft method, for development use, may change without warning ***
// Set timer interval. Returns 0 if OK, -1 on failure.
// This method is slow, canceling the timer and adding a new one yield better performance.
CZMQ_EXPORT int
ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval);
// *** Draft method, for development use, may change without warning ***
// Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure.
// This method is slow, canceling the timer and adding a new one yield better performance.
CZMQ_EXPORT int
ztimerset_reset (ztimerset_t *self, int timer_id);
// *** Draft method, for development use, may change without warning ***
// Return the time until the next interval.
// Should be used as timeout parameter for the zpoller wait method.
// The timeout is in msec.
CZMQ_EXPORT int
ztimerset_timeout (ztimerset_t *self);
// *** Draft method, for development use, may change without warning ***
// Invoke callback function of all timers which their interval has elapsed.
// Should be call after zpoller wait method.
// Returns 0 if OK, -1 on failure.
CZMQ_EXPORT int
ztimerset_execute (ztimerset_t *self);
// *** Draft method, for development use, may change without warning ***
// Self test of this class.
CZMQ_EXPORT void
ztimerset_test (bool verbose);
#endif // CZMQ_BUILD_DRAFT_API
Please add '@interface' section in './../src/ztimerset.c'.
π«Ά bestie that#ifdef CZMQ_BUILD_DRAFT_APIis NOT decorative. this whole class is draft β disabled in stable builds by default. if you actually wanna use it, ask for it to be pushed to stable state, and enable it with--enable-drafts. fr fr.
π¦ DESCRIPTION π¦
ztimerset β timer set β¨
Please add @discuss section in ./../src/ztimerset.c.
(yeah that's genuinely all the description we got, she's mysterious like that π)
π EXAMPLE π
straight from the ztimerset_test method, no cap:
// Simple create/destroy test
ztimerset_t *self = ztimerset_new ();
assert (self);
// Adding timer
bool timer_invoked = false;
int timer_id = ztimerset_add (self, 100, handler, &timer_invoked);
assert (timer_id != -1);
int rc = ztimerset_execute (self);
assert (rc == 0);
assert (!timer_invoked);
int timeout = ztimerset_timeout (self);
assert (timeout > 0);
zclock_sleep (timeout);
rc = ztimerset_execute (self);
assert (rc == 0);
assert (timer_invoked);
// Cancel timer
timeout = ztimerset_timeout (self);
assert (timeout > 0);
rc = ztimerset_cancel (self, timer_id);
assert (rc == 0);
timeout = ztimerset_timeout (self);
assert(timeout == -1);
// Reset a timer
timer_id = ztimerset_add (self, 100, handler, &timer_invoked);
assert (timer_id != -1);
timeout = ztimerset_timeout (self);
assert (timeout > 0);
zclock_sleep (timeout / 2);
timeout = ztimerset_timeout (self);
rc = ztimerset_reset(self, timer_id);
assert (rc == 0);
int timeout2 = ztimerset_timeout (self);
assert (timeout2 > timeout);
rc = ztimerset_cancel (self, timer_id);
assert (rc == 0);
// Set interval
timer_id = ztimerset_add (self, 100, handler, &timer_invoked);
assert (timer_id != -1);
timeout = ztimerset_timeout (self);
rc = ztimerset_set_interval(self, timer_id, 200);
timeout2 = ztimerset_timeout (self);
assert (timeout2 > timeout);
ztimerset_destroy (&self);
#if defined (__WINDOWS__)
zsys_shutdown();
#endif
likeβ¦ she really said "here's the whole lifecycle, watch me work" π
π AUTHORS π
the czmq manual was written by the authors in the AUTHORS file. give them their flowers π
π₯ RESOURCES π₯
main web site:
report bugs to the email zeromq-dev@lists.zeromq.org[1]
π COPYRIGHT π
Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. LICENSE included with the czmq distribution.
β NOTES β
zeromq-dev@lists.zeromq.orgβmailto:zeromq-dev@lists.zeromq.org
okay that's the whole page, you ate it, you understood it, periodt π β¨
signing off with the receipts: this was CZMQ 4.2.1, dated 01/16/2026 β love that for us ππ¦π
π¦ where this page comes from
- fedora 44: czmq-devel 4.2.1-24.fc44 Β· MPL-2.0
- fedora 44: czmq-devel 4.2.1-24.fc44 Β· MPL-2.0
- ubuntu resolute: libczmq-dev 4.2.1-3build1 Β· MPL-2.0
- ubuntu stonking: libczmq-dev 4.2.1-3build1 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms