---
name: "iom_init"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/iom_init"
---

# iom\_init(3)

create new I/O multiplexer

## NAME

iom\_init - create new I/O multiplexer

## SYNTAX

**#include \<libowfat/io.h\>**

int **iom\_init**(iomux\_t\* c);

## DESCRIPTION

iom\_init initializes an I/O multiplexer.

An I/O multiplexer is a context that can be used to do I/O multiplexing with support for multiple threads. Add events to a multiplexer using *iom\_add*, and then get the next available event with *iom\_wait*. If you are done and want to signal all the threads something, set a volatile global variable to tell the threads to stop and then fall *iom\_abort* to tell all pending iom\_wait operations in all threads to return immediately.

After *iom\_init* is done, *iom\_add* and *iom\_wait* can be called from different threads on the same context, and they will synchronize internally.

## LINKING

You may have to add *-lpthread* to the command line in the linking step.

## RETURN VALUE

iom\_init returns 0 on success and -1 on error, setting errno.

## SEE ALSO

iom\_add, iom\_wait, iom\_abort
