openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

180 lines
6.1 KiB

'\" t
.\" Title: ztimerset
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
.\" Date: 12/31/2016
.\" Manual: CZMQ Manual
.\" Source: CZMQ 4.0.2
.\" Language: English
.\"
.TH "ZTIMERSET" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ztimerset \- timer set
.SH "SYNOPSIS"
.sp
.nf
// 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 \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/ztimerset\&.c\*(Aq\&.
.fi
.SH "DESCRIPTION"
.sp
ztimerset \- timer set
.sp
Please add \fI@discuss\fR section in \fI\&./\&.\&./src/ztimerset\&.c\fR\&.
.SH "EXAMPLE"
.PP
\fBFrom ztimerset_test method\fR.
.sp
.if n \{\
.RS 4
.\}
.nf
// 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);
.fi
.if n \{\
.RE
.\}
.sp
.SH "AUTHORS"
.sp
The czmq manual was written by the authors in the AUTHORS file\&.
.SH "RESOURCES"
.sp
Main web site: \m[blue]\fB\%\fR\m[]
.sp
Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
.SH "COPYRIGHT"
.sp
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\&.
.SH "NOTES"
.IP " 1." 4
zeromq-dev@lists.zeromq.org
.RS 4
\%mailto:zeromq-dev@lists.zeromq.org
.RE