![]() |
![]()
| ![]() |
![]()
NAMEztimerset - Class for timer set SYNOPSIS// 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) ( DESCRIPTIONztimerset - timer set Please add @discuss section in ./../src/ztimerset.c. EXAMPLEFrom ztimerset_test method. // 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 AUTHORSThe czmq manual was written by the authors in the AUTHORS file. RESOURCESMain web site: Report bugs to the email <zeromq-dev@lists.zeromq.org[1]> COPYRIGHTCopyright (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
mailto:zeromq-dev@lists.zeromq.org
|