-
Notifications
You must be signed in to change notification settings - Fork 2
/
quark_queue_get_epollfd.3
69 lines (65 loc) · 1.58 KB
/
quark_queue_get_epollfd.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
.Dd $Mdocdate$
.Dt QUARK_QUEUE_GET_EPOLLFD 3
.Os
.Sh NAME
.Nm quark_queue_get_epollfd
.Nd fetch a file descriptor suitable for blocking with
.Xr epoll_wait 2
.Sh SYNOPSIS
.In quark.h
.Ft int
.Fn quark_queue_get_epollfd "struct quark_queue *qq"
.Sh DESCRIPTION
.Nm
retrieves a epoll file descriptor with all the backend related descriptors
already registered to it.
This is to be used for integrating quark into an existing main-loop, as in, not
calling
.Xr quark_queue_block 3
at all.
.Pp
It is
.Em VERY IMPORTANT
to establish a reasonable timeout when you call
.Xr epoll_wait 2
on it.
Some backends will only make the file descriptor readable once a certain
watermark of bytes have been read, so without the timeout you might get very
late events.
100ms is a safe value, the user should then call
.Xr quark_queue_get_events 3
to fetch the expired events.
.Sh RETURN VALUES
Returns the epoll file descriptor or -1 if deemed invalid, as trying to get the
descriptor of a closed queue.
.Va errno
is set.
.Sh EXAMPLES
.Bd -literal -offset indent
#include <sys/epoll.h>
#include <quark.h>
static int
my_own_blocking(struct quark_queue *qq)
{
int epollfd;
epollfd = quark_queue_get_epollfd(qq);
if (epollfd == -1)
return (-1);
if (epoll_wait(qq->epollfd, &ev, 1, 100) == -1)
return (-1);
return (0);
}
.Ed
.Sh SEE ALSO
.Xr quark_event_dump 3 ,
.Xr quark_process_lookup 3 ,
.Xr quark_queue_block 3 ,
.Xr quark_queue_close 3 ,
.Xr quark_queue_default_attr 3 ,
.Xr quark_queue_get_events 3 ,
.Xr quark_queue_get_stats 3 ,
.Xr quark_queue_open 3 ,
.Xr quark 7 ,
.Xr quark-btf 8 ,
.Xr quark-mon 8 ,
.Xr quark-test 8