[英]Is epoll thread-safe?
epoll中有兩個功能:
當我使用相同的 epoll_fd 時它們是線程安全的嗎? 如果一個線程調用 epoll_wait 而其他線程同時調用 epoll_ctl 會發生什么?
它是線程安全的,但沒有太多文檔明確說明這一點。 看這里
順便說一句,您也可以讓多個線程在單個epoll_fd上等待,但在這種情況下,它會變得有點棘手。 (即,您可能想使用邊緣觸發的EPOLLET或 oneshot 模式EPOLLONESHOT 。請參見此處。)
epoll_fd
EPOLLET
EPOLLONESHOT
注意:現有接受的答案是正確的,但它提到“沒有多少文檔明確指出”,而 epoll 文檔確實 state 。
epoll_wait的 手冊頁明確允許在另一個線程中等待時將文件描述符添加到 epoll 集中:
epoll_wait
“注釋”部分:
當一個線程在對epoll_wait()的調用中被阻塞時,另一個線程可以將文件描述符添加到等待的epoll實例中。 如果新的文件描述符准備就緒,它將導致epoll_wait()調用解除阻塞。
[英]Is accept() thread-safe?
[英]Is perror thread-safe?
[英]Is `asprintf` thread-safe?
[英]Is errno thread-safe?
[英]Is malloc thread-safe?
[英]Is ARPACK thread-safe?
[英]Is it thread-safe to strcmp?
[英]Are system calls thread-safe?
[英]Thread-safe file updates
[英]Is giflib 5.1.2 not thread-safe?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.