Lely core libraries  2.2.5
poll.c File Reference

This file is part of the I/O library; it contains the I/O polling implementation for POSIX platforms. More...

#include "io.h"
#include <lely/io2/posix/poll.h>
#include <lely/util/dllist.h>
#include <lely/util/util.h>
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <poll.h>
Include dependency graph for poll.c:

Go to the source code of this file.

Data Structures

struct  io_poll_thrd
 
struct  io_poll
 

Functions

io_poll_tio_poll_create (io_ctx_t *ctx, int signo)
 Creates a new I/O polling instance. More...
 
void io_poll_destroy (io_poll_t *poll)
 Destroys an I/O polling interface. More...
 
io_ctx_tio_poll_get_ctx (const io_poll_t *poll)
 Returns a pointer to the I/O context with which the I/O polling instance is registered.
 
ev_poll_tio_poll_get_poll (const io_poll_t *poll)
 Returns a pointer to the ev_poll_t instance corresponding to the I/O polling instance.
 
int io_poll_watch (io_poll_t *poll, int fd, int events, struct io_poll_watch *watch)
 Registers a file descriptor with an I/O polling instance and monitors it for I/O events (through ev_poll_wait()). More...
 

Detailed Description

This file is part of the I/O library; it contains the I/O polling implementation for POSIX platforms.

See also
lely/io2/posix/poll.h
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 poll.c.

Function Documentation

◆ io_poll_create()

io_poll_t* io_poll_create ( io_ctx_t ctx,
int  signo 
)

Creates a new I/O polling instance.

Parameters
ctxa pointer to the I/O context with which the polling instance should be registered.
signothe signal number used to wake up threads waiting on io_poll_watch() with ev_poll_kill(). If signo is 0, the default value SIGUSR1 is used.
Returns
a pointer to the new polling instance, or NULL on error. In the latter case, the error number can be obtained from errno.

Definition at line 236 of file poll.c.

◆ io_poll_destroy()

void io_poll_destroy ( io_poll_t poll)

Destroys an I/O polling interface.

Destroys an I/O polling instance.

See also
io_poll_create()

Definition at line 263 of file poll.c.

◆ io_poll_watch()

int io_poll_watch ( io_poll_t poll,
int  fd,
int  events,
struct io_poll_watch watch 
)

Registers a file descriptor with an I/O polling instance and monitors it for I/O events (through ev_poll_wait()).

Parameters
polla pointer to an I/O polling instance.
fdthe file descriptor to be monitored.
eventsthe I/O events to monitor (any combination of IO_EVENT_IN, IO_EVENT_PRI, IO_EVENT_OUT, IO_EVENT_ERR and IO_EVENT_HUP). If events is non-zero the file descriptor is (re)registered and monitored for the specified events. Note that error and disconnect events are monitored regardless of whether IO_EVENT_ERR and IO_EVENT_HUP are specified. If events is 0, the file descriptor is unregistered.
watcha pointer to an I/O event monitor. If fd has already been registered with a different io_poll_watch object, an error is returned and errno is set to EEXIST.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained from errno.

Definition at line 284 of file poll.c.