Open defineYIDA opened 4 years ago
The <self-pipe trick>}, implemented using a pair of sockets rather than pipes (due to the lack of support in select() on Windows for pipes), used to wake up the main loop from another thread.
解决方式:
1)unix:self-pipe trick
2)win:a pair socket
注意:
无论是通过pipe
还是socket
来实现,都是通过描述符的就绪事件来激活复用函数,通过往一个注册的描述符中写入一个字符来唤醒。
那么对于水平触发(LE)的模型,一定得把这个字符给处理了,不然会一直处于就绪状态导致空轮询。
How to signal select() to return immediately? Select on multiple pipes Selector的wakeup方法 NIO的selector.wakeup的实现