Lely core libraries  2.3.4
timer.h File Reference

This header file is part of the I/O library; it contains the user-defined timer declarations. More...

#include <lely/io2/timer.h>
Include dependency graph for timer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void io_user_timer_setnext_t(const struct timespec *tp, void *arg)
 The type of function invoked by a user-defined timer when the expiration time is updated with io_timer_settime() or when a periodic timer expires. More...
 

Functions

io_timer_tio_user_timer_create (io_ctx_t *ctx, ev_exec_t *exec, io_user_timer_setnext_t *func, void *arg)
 Creates a new user-defined timer. More...
 
void io_user_timer_destroy (io_timer_t *timer)
 Destroys a user-defined timer. More...
 

Detailed Description

This header file is part of the I/O library; it contains the user-defined timer declarations.

The user-defined timer is a passive timer; it does not actively monitor a system clock, but provides a clock which requires the user to periodically update the time with io_clock_settime(). These updates then trigger timer expirations. The timer can optionally notify the user of expiration time updates. These updates can be used by an application to determine when to invoke io_clock_settime().

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file timer.h.

Typedef Documentation

◆ io_user_timer_setnext_t

typedef void io_user_timer_setnext_t(const struct timespec *tp, void *arg)

The type of function invoked by a user-defined timer when the expiration time is updated with io_timer_settime() or when a periodic timer expires.

Parameters
tpa pointer to the next expiration time.
argthe user-specific value submitted to io_user_timer_create().

Definition at line 45 of file timer.h.

Function Documentation

◆ io_user_timer_create()

io_timer_t* io_user_timer_create ( io_ctx_t ctx,
ev_exec_t exec,
io_user_timer_setnext_t func,
void *  arg 
)

Creates a new user-defined timer.

Parameters
ctxa pointer to the I/O context with which the timer should be registered.
execa pointer to the executor used to execute asynchronous tasks.
funca pointer to the function to be invoked when the expiration time is updated (can be NULL).
argthe user-specific value to be passed as the second argument to func.
Returns
a pointer to a new timer, or NULL on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 213 of file timer.c.

◆ io_user_timer_destroy()

void io_user_timer_destroy ( io_timer_t timer)

Destroys a user-defined timer.

See also
io_user_timer_create()

Definition at line 241 of file timer.c.