Class: LightIO::Core::Backend::NIO
- Inherits:
- 
      Object
      
        - Object
- LightIO::Core::Backend::NIO
 
- Extended by:
- Forwardable
- Defined in:
- lib/lightio/core/backend/nio.rb
Overview
LightIO use NIO as default event-driving backend
Instance Attribute Summary collapse
- 
  
    
      #running  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute running. 
Instance Method Summary collapse
- #add_callback(&blk) ⇒ Object
- #add_io_wait(io, interests, &blk) ⇒ Object
- #add_timer(timer) ⇒ Object
- #cancel_io_wait(io) ⇒ Object
- #cancel_timer(timer) ⇒ Object
- #env_backend ⇒ Object
- 
  
    
      #initialize  ⇒ NIO 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of NIO. 
- #run ⇒ Object
- #stop ⇒ Object (also: #close)
Constructor Details
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
| 56 57 58 | # File 'lib/lightio/core/backend/nio.rb', line 56 def running @running end | 
Instance Method Details
#add_callback(&blk) ⇒ Object
| 79 80 81 | # File 'lib/lightio/core/backend/nio.rb', line 79 def add_callback(&blk) @callbacks << blk end | 
#add_io_wait(io, interests, &blk) ⇒ Object
| 91 92 93 94 95 | # File 'lib/lightio/core/backend/nio.rb', line 91 def add_io_wait(io, interests, &blk) monitor = @selector.register(io, interests) monitor.value = blk monitor end | 
#add_timer(timer) ⇒ Object
| 83 84 85 | # File 'lib/lightio/core/backend/nio.rb', line 83 def add_timer(timer) timer.uuid = @timers.add_timer(timer) end | 
#cancel_io_wait(io) ⇒ Object
| 97 98 99 | # File 'lib/lightio/core/backend/nio.rb', line 97 def cancel_io_wait(io) @selector.deregister(io) end | 
#cancel_timer(timer) ⇒ Object
| 87 88 89 | # File 'lib/lightio/core/backend/nio.rb', line 87 def cancel_timer(timer) @timers.cancel_timer(timer) end | 
#env_backend ⇒ Object
| 109 110 111 112 | # File 'lib/lightio/core/backend/nio.rb', line 109 def env_backend key = 'LIGHTIO_BACKEND'.freeze ENV.has_key?(key) ? ENV[key].to_sym : nil end | 
#run ⇒ Object
| 67 68 69 70 71 72 73 74 75 76 | # File 'lib/lightio/core/backend/nio.rb', line 67 def run raise Error, "already running" if @running @running = true loop do @current_loop_time = Time.now run_timers run_callbacks handle_selectables end end | 
#stop ⇒ Object Also known as: close
| 101 102 103 104 105 | # File 'lib/lightio/core/backend/nio.rb', line 101 def stop return if closed? @running = false @selector.close end |