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_
ev_task_from_node
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
io2.h
ev_exec_t
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
io_sigset_wait
A wait operation suitable for use with a signal handler.
Definition: sigset.h:43
exec.h
sigset.h
io_sigset_wait::signo
int signo
The signal number, or 0 if the wait operation was canceled.
Definition: sigset.h:50
ev_exec_on_task_fini
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
stdint.h
sllist_pop_front
struct slnode * sllist_pop_front(struct sllist *list)
Pops a node from the front of a singly-linked list.
Definition: sllist.h:243
sllist
A singly-linked list.
Definition: sllist.h:52
ev_task
An executable task.
Definition: task.h:41
io_sigset_wait_from_task
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
ev_exec_post
void ev_exec_post(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:124
slnode
A node in a singly-linked list.
Definition: sllist.h:40
io_sigset_wait::task
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the wait operation.
Definition: sigset.h:48
ev_task::exec
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition: task.h:43