defineYIDA / Reactor

Reactor for python
14 stars 0 forks source link

Done-Win下对select的唤醒的实现 #1

Open defineYIDA opened 4 years ago

defineYIDA commented 4 years ago

How to signal select() to return immediately? Select on multiple pipes Selector的wakeup方法 NIO的selector.wakeup的实现

defineYIDA commented 4 years ago

src/twisted/internet/posixbase.py

defineYIDA commented 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.

defineYIDA commented 4 years ago

解决方式: 1)unix:self-pipe trick 2)win:a pair socket 注意: 无论是通过pipe还是socket来实现,都是通过描述符的就绪事件来激活复用函数,通过往一个注册的描述符中写入一个字符来唤醒。 那么对于水平触发(LE)的模型,一定得把这个字符给处理了,不然会一直处于就绪状态导致空轮询。

defineYIDA commented 4 years ago

Reactor/blob/master/src/util/waker.py