Is epoll thread-safe?

前端 未结 2 2015
梦如初夏
梦如初夏 2020-12-23 17:04

There are two functions in epoll:

  1. epoll_ctl
  2. epoll_wait

Are they thread-safe when I use the same epoll_fd?
What wi

2条回答
  •  悲&欢浪女
    2020-12-23 17:17

    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.)

提交回复
热议问题