Lely core libraries  2.3.4
sigset.h
Go to the documentation of this file.
1 
22 #ifndef LELY_IO2_INTERN_SIGSET_H_
23 #define LELY_IO2_INTERN_SIGSET_H_
24 
25 #include "io2.h"
26 #include <lely/ev/exec.h>
27 #include <lely/io2/sigset.h>
28 
29 #include <stdint.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 static void io_sigset_wait_post(struct io_sigset_wait *wait, int signo);
36 static size_t io_sigset_wait_queue_post(struct sllist *queue, int signo);
37 
38 static inline void
39 io_sigset_wait_post(struct io_sigset_wait *wait, int signo)
40 {
41  wait->signo = signo;
42 
43  ev_exec_t *exec = wait->task.exec;
44  ev_exec_post(exec, &wait->task);
46 }
47 
48 static inline size_t
49 io_sigset_wait_queue_post(struct sllist *queue, int signo)
50 {
51  size_t n = 0;
52 
53  struct slnode *node;
54  while ((node = sllist_pop_front(queue))) {
55  struct ev_task *task = ev_task_from_node(node);
57  io_sigset_wait_post(wait, signo);
58  n += n < SIZE_MAX;
59  }
60 
61  return n;
62 }
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif // !LELY_IO2_INTERN_SIGSET_H_
This header file is part of the event library; it contains the abstract task executor interface.
void ev_exec_post(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:124
void ev_exec_on_task_fini(ev_exec_t *exec)
Undoes the effect of a previous call to ev_exec_on_task_init().
Definition: exec.h:112
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
This header file is part of the I/O library; it contains the abstract signal handler interface.
struct io_sigset_wait * io_sigset_wait_from_task(struct ev_task *task)
Obtains a pointer to a signal wait operation from a pointer to its completion task.
Definition: sigset.c:62
struct slnode * sllist_pop_front(struct sllist *list)
Pops a node from the front of a singly-linked list.
Definition: sllist.h:243
This is the internal header file of the I/O library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdint....
An executable task.
Definition: task.h:41
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition: task.h:43
A wait operation suitable for use with a signal handler.
Definition: sigset.h:43
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the wait operation.
Definition: sigset.h:48
int signo
The signal number, or 0 if the wait operation was canceled.
Definition: sigset.h:50
A singly-linked list.
Definition: sllist.h:52
A node in a singly-linked list.
Definition: sllist.h:40
struct ev_task * ev_task_from_node(struct slnode *node)
Converts a pointer to a node in a queue to the address of the task containing the node.
Definition: task.c:32