iv\_timer(3) ivykis programmer's manual iv\_timer(3)

# [NAME](#NAME)

iv\_timer\_register, iv\_timer\_unregister, iv\_timer\_registered - deal with ivykis timers

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;iv.h&gt;**

```
struct iv_timer {


        struct timespec         expires;


        void                    *cookie;


        void                    (*handler)(void *);
};
```

**void IV\_TIMER\_INIT(struct iv\_timer \*timer);**  
**void iv\_timer\_register(struct iv\_timer \*timer);**  
**void iv\_timer\_unregister(struct iv\_timer \*timer);**  
**int iv\_timer\_registered(const struct iv\_timer \*timer);**

# [DESCRIPTION](#DESCRIPTION)

The functions **iv\_timer\_register** and **iv\_timer\_unregister** register, respectively unregister, a timer with the current thread's ivykis event loop. **iv\_timer\_registered** on a timer returns true if that timer is currently registered with ivykis.

When a timer that is registered becomes 'ready', due to the current system clock value becoming greater than or equal to the timer's **-&gt;expires** member field, the callback function specified by **-&gt;handler** is called in the thread that the timer was registered in, with **-&gt;cookie** as its first and sole argument. When this happens, the timer is transparently unregistered.

The application is allowed to change the **-&gt;cookie** and **-&gt;handler** members at any time. The application is not allowed to change the **-&gt;expires** member while the timer is registered.

A given **struct iv\_timer** can only be registered in one thread at a time, and a timer can only be unregistered in the thread that it was registered from.

There is no limit on the number of timers registered at once.

See [**iv\_examples**(3)](/man/os/ivykis/iv_examples.3) for programming examples.

# [SEE ALSO](#SEE_ALSO)

[**ivykis**(3)](/man/os/ivykis/ivykis.3), [**iv\_examples**(3)](/man/os/ivykis/iv_examples.3)

2010-08-15 ivykis

---

Document: iv_timer(3) from ivykis 0.43.2-r9 (Chainguard OS)
Source: https://github.com/buytenh/ivykis
