1 # -*- encoding: binary -*-
3 module Rainbows::Fiber::Rev::Methods
4 class Watcher < Rev::IOWatcher
5 def initialize(fio, flag)
8 attach(Rev::Loop.default)
15 alias on_writable on_readable
19 @w.detach if defined?(@w) && @w.attached?
20 @r.detach if defined?(@r) && @r.attached?
24 def kgio_wait_writable
25 @w = Watcher.new(self, :w) unless defined?(@w)
26 @w.enable unless @w.enabled?
31 def kgio_wait_readable
32 @r = Watcher.new(self, :r) unless defined?(@r)
33 @r.enable unless @r.enabled?
43 # the next two trigger autoload, ugh, oh well...
44 Rainbows::Fiber::IO::Socket,
45 Rainbows::Fiber::IO::Pipe
47 klass.__send__(:include, Rainbows::Fiber::Rev::Methods)