maph 1.0.0 High-Performance Memory-Mapped Key-Value Database with O(1) Lookups

Loading...
Searching...
No Matches
epoll_kqueue.h
Go to the documentation of this file.
1/*
2 * Authored by Alex Hultman, 2018-2019.
3 * Intellectual property of third-party.
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef EPOLL_KQUEUE_H
19#define EPOLL_KQUEUE_H
20
21#include "internal/loop_data.h"
22
23#ifdef LIBUS_USE_EPOLL
24#include <sys/epoll.h>
25#include <sys/timerfd.h>
26#include <sys/eventfd.h>
27#define LIBUS_SOCKET_READABLE EPOLLIN
28#define LIBUS_SOCKET_WRITABLE EPOLLOUT
29#else
30#include <sys/event.h>
31/* Kqueue's EVFILT_ is NOT a bitfield, you cannot OR together them.
32 * We therefore have our own bitfield we then translate in every call */
33#define LIBUS_SOCKET_READABLE 1
34#define LIBUS_SOCKET_WRITABLE 2
35#endif
36
37 struct us_loop_t {
38 alignas(LIBUS_EXT_ALIGNMENT) struct us_internal_loop_data_t data;
39
40 /* Number of non-fallthrough polls in the loop */
41 int num_polls;
42
43 /* Number of ready polls this iteration */
44 int num_ready_polls;
45
46 /* Current index in list of ready polls */
47 int current_ready_poll;
48
49 /* Loop's own file descriptor */
50 int fd;
51
52 /* The list of ready polls */
53#ifdef LIBUS_USE_EPOLL
54 struct epoll_event ready_polls[1024];
55#else
56 struct kevent ready_polls[1024];
57#endif
58};
59
60 struct us_poll_t {
61 alignas(LIBUS_EXT_ALIGNMENT) struct {
62 signed int fd : 28; // we could have this unsigned if we wanted to, -1 should never be used
63 unsigned int poll_type : 4;
64 } state;
65};
66
67#endif // EPOLL_KQUEUE_H
LIBUS_EXT_ALIGNMENT
#define LIBUS_EXT_ALIGNMENT
Definition libusockets.h:28
us_loop_t::fd
int fd
Definition epoll_kqueue.h:50
us_poll_t::fd
LIBUS_SOCKET_DESCRIPTOR fd
Definition asio.h:40
us_poll_t::state
struct us_poll_t::@0 state
us_loop_t::num_polls
int num_polls
Definition epoll_kqueue.h:41
us_loop_t::num_ready_polls
int num_ready_polls
Definition epoll_kqueue.h:44
us_loop_t::current_ready_poll
int current_ready_poll
Definition epoll_kqueue.h:47
us_loop_t::ready_polls
struct kevent ready_polls[1024]
Definition epoll_kqueue.h:56
us_loop_t::data
struct us_internal_loop_data_t data
Definition asio.h:27
us_poll_t::poll_type
unsigned char poll_type
Definition asio.h:41
us_poll_t
Definition asio.h:37
us_loop_t
Definition asio.h:26
loop_data.h
us_internal_loop_data_t
Definition loop_data.h:21