There are two functions in epoll:
Are they thread-safe when I use the same epoll_fd?
What will happen if one thread calls epoll_wait and others call epoll_ctl at the same time?
It is thread-safe, but there isn't much documentation that explicitly states that. See here
BTW, you can also have multiple threads waiting on a single epoll_fd
, but in that case it can get a bit tricky. (I.e. you might want to use edge-triggered EPOLLET
or oneshot mode EPOLLONESHOT
. See here.)