Create Your Own Event Queue 74 I'll get back to explaining what these constants are in a moment. Let's first take a look at the syscalls we need to make. Fortunately, we've already covered syscalls in detail, so you already know the basics of ffi and why we link to C in the preceding code: epoll_create is the syscall we make to create an epoll queue. Y ou can find the documentation for it at https://man7. org/linux/man-pages/man2/epoll_create. 2. html. This method accepts one argument called size, but size is there only for historical reasons. The argument will be ignored but must have a value larger than 0. close is the syscall we need to close the file descriptor we get when we create our epoll instance, so we release our resources properly. Y ou can read the documentation for the syscall at https://man7. org/linux/man-pages/man2/close. 2. html. epoll_ctl is the control interface we use to perform operations on our epoll instance. This is the call we use to register interest in events on a source. It supports three main operations: add, modify, or delete. The first argument, epfd, is the epoll file descriptor we want to perform operations on. The second argument, op, is the argument where we specify whether we want to perform an add, modify, or delete operation In our case, we're only interested in adding interest for events, so we'll only pass in EPOLL_ CTL_ADD, which is the value to indicate that we want to perform an add operation. epoll_ event is a little more complicated, so we'll discuss it in more detail. It does two important things for us: first, the events field indicates what kind of events we want to be notified of and it can also modify the behavior of how and when we get notified. Second, the data field passes on a piece of data to the kernel that it will return to us when an event occurs. The latter is important since we need this data to identify exactly what event occurred since that's the only information we'll receive in return that can identify what source we got the notification for. Y ou can find the documentation for this syscall here: https://man7. org/linux/ man-pages/man2/epoll_ctl. 2. html. epoll_wait is the call that will block the current thread and wait until one of two things happens: we receive a notification that an event has occurred or it times out. epfd is the epoll file descriptor identifying the queue we made with epoll_create. events is an array of the same Event structure we used in epoll_ctl. The difference is that the events field now gives us information about what event did occur, and importantly the data field contains the same data that we passed in when we registered interest For example, the data field lets us identify which file descriptor has data that's ready to be read. The maxevents arguments tell the kernel how many events we have reserved space for in our array. Lastly, the timeout argument tells the kernel how long we will wait for events before it will wake us up again so we don't potentially block forever. Y ou can read the documentation for epoll_wait at https://man7. org/linux/man-pages/man2/ epoll_wait. 2. html.