iv\_event\_raw(3) ivykis programmer's manual iv\_event\_raw(3)

# [NAME](#NAME)

IV\_EVENT\_RAW\_INIT, iv\_event\_raw\_register, iv\_event\_raw\_unregister, iv\_event\_raw\_post - manage ivykis objects for event notification

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;iv\_event\_raw.h&gt;**

```
struct iv_event_raw {


        void            *cookie;


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

**void IV\_EVENT\_RAW\_INIT(struct iv\_event\_raw \*this);**  
**int iv\_event\_raw\_register(struct iv\_event\_raw \*this);**  
**void iv\_event\_raw\_unregister(struct iv\_event\_raw \*this);**  
**void iv\_event\_raw\_post(const struct iv\_event\_raw \*this);**

# [DESCRIPTION](#DESCRIPTION)

**iv\_event\_raw** provides a way for delivering events to [**ivykis**(3)](/man/os/ivykis/ivykis.3) recipients across thread and process boundaries.

The intended event recipient calls **IV\_EVENT\_RAW\_INIT** on a **struct iv\_event\_raw** object, fills in **-&gt;cookie** and **-&gt;handler,** and then calls **iv\_event\_raw\_register** on the object.

To generate an event, call **iv\_event\_raw\_post** on the previously initialized **struct iv\_event\_raw** object. This will cause the callback specified by **-&gt;handler** to be called in the thread that the **struct iv\_event\_raw** object was registered in, with **-&gt;cookie** as its sole argument.

To deinitialize a **struct iv\_event\_raw** object, call **iv\_event\_raw\_unregister** from the same thread that **iv\_event\_raw\_register** was called from on that object.

It is permitted to unregister a **struct iv\_event\_raw** object from any ivykis callback function in the thread it was registered in, including from a callback function triggered by this object, and it is permitted to free the memory corresponding to an unregistered object from its own callback function.

**iv\_event\_raw\_post** can be called from the same thread that **iv\_event\_raw\_register** was called from, from a different thread in the same process, or even from a different process, and can safely be called from signal handlers.

If posting an event only ever needs to be done from within the same process, see [**iv\_event**(3)](/man/os/ivykis/iv_event.3) for a lighter-weight alternative to **iv\_event\_raw.**

Internally, **iv\_event\_raw** is implemented by registering a file descriptor (a struct [**iv\_fd**(3)](/man/os/ivykis/iv_fd.3)) with the recipient thread's ivykis event loop, and by causing that file descriptor to become readable upon a call to **iv\_event\_raw\_post.**

If [**eventfd**(2)](/man/os/ivykis/eventfd.2) is available, it will be used to procure the abovementioned file descriptor. If not, **iv\_event\_raw** will fall back to [**pipe**(2)](/man/os/ivykis/pipe.2) as the source of its file descriptors. [**eventfd**(2)](/man/os/ivykis/eventfd.2) is preferred as it requires only one file descriptor table entry (while [**pipe**(2)](/man/os/ivykis/pipe.2) requires two), and has much less kernel overhead than [**pipe**(2)](/man/os/ivykis/pipe.2) has.

# [SEE ALSO](#SEE_ALSO)

[**ivykis**(3)](/man/os/ivykis/ivykis.3), [**iv\_event**(3)](/man/os/ivykis/iv_event.3), [**eventfd**(2)](/man/os/ivykis/eventfd.2), [**pipe**(2)](/man/os/ivykis/pipe.2)

2010-09-02 ivykis

---

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