GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
ZTIMERSET(3) CZMQ Manual ZTIMERSET(3)

ztimerset - Class for timer set

//  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'.

ztimerset - timer set

Please add @discuss section in ./../src/ztimerset.c.

From 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

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

Main web site:

Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>

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.

1.
zeromq-dev@lists.zeromq.org
mailto:zeromq-dev@lists.zeromq.org
04/09/2022 CZMQ 4.2.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.