QUARK_QUEUE_GET_EPOLLFD(3) | Library Functions Manual | QUARK_QUEUE_GET_EPOLLFD(3) |
quark_queue_get_epollfd
—
fetch a file descriptor suitable for blocking with
epoll_wait(2)
#include
<quark.h>
int
quark_queue_get_epollfd
(struct
quark_queue *qq);
quark_queue_get_epollfd
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
quark_queue_block(3) at all.
It is VERY IMPORTANT to establish a reasonable timeout when you call 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 quark_queue_get_event(3) to fetch the expired event.
Returns the epoll file descriptor or -1 if deemed invalid, as trying to get the descriptor of a closed queue. errno is set.
#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); }
quark_event_dump(3), quark_process_lookup(3), quark_queue_block(3), quark_queue_close(3), quark_queue_default_attr(3), quark_queue_get_event(3), quark_queue_get_stats(3), quark_queue_open(3), quark(7), quark-btf(8), quark-mon(8), quark-test(8)
December 1, 2024 | Linux |