diff options
Diffstat (limited to 'lib/rainbows/epoll/state.rb')
-rw-r--r-- | lib/rainbows/epoll/state.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/rainbows/epoll/state.rb b/lib/rainbows/epoll/state.rb new file mode 100644 index 0000000..6e554be --- /dev/null +++ b/lib/rainbows/epoll/state.rb @@ -0,0 +1,22 @@ +# -*- encoding: binary -*- +# :enddoc: +# used to keep track of state for each descriptor and avoid +# unneeded syscall or ENONENT overhead +module Rainbows::Epoll::State + EP = SleepyPenguin::Epoll.new + + def epoll_disable + @epoll_active or return + @epoll_active = false + EP.del(self) + end + + def epoll_enable(flags) + if @epoll_active + flags == @epoll_active or + EP.mod(self, @epoll_active = flags) + else + EP.add(self, @epoll_active = flags) + end + end +end |