Sha256: d619bacbb425180515066b550ec44c692de2ce9b71d7b5bb1a467955a6845524
Contents?: true
Size: 649 Bytes
Versions: 3
Compression:
Stored size: 649 Bytes
Contents
module EventLoop class << self SELECTOR = NIO::Selector.new def register(io, interest=(:rw), &callback) monitor = SELECTOR.register(io, interest) monitor.value = callback end def unregister(io) SELECTOR.deregister(io) end def run_once SELECTOR.select(1) do |monitor| # Timeout for 1 secs monitor.value.call(monitor) end end def start return if running? @stop = false until @stop run_once end @stop = nil end def stop @stop = true end def running? @stop = true if @stop.nil? !@stop end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
em-midori-0.1.11 | lib/midori/core_ext/event_loop.rb |
em-midori-0.1.10 | lib/midori/core_ext/event_loop.rb |
em-midori-0.1.9 | lib/midori/core_ext/event_loop.rb |