Class: Plux::Reactor

Inherits:
Object
  • Object
show all
Defined in:
lib/plux/reactor.rb

Defined Under Namespace

Classes: Worker

Instance Method Summary collapse

Constructor Details

#initialize(count, worker) ⇒ Reactor

Returns a new instance of Reactor.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/plux/reactor.rb', line 3

def initialize(count, worker)
  @worker = worker
  @msg_q = Queue.new
  @count = count

  @nio = NIO::Selector.new
  @newly_accepted = Queue.new
  @closed = []

  receive
  process
end

Instance Method Details

#register(socket) ⇒ Object



16
17
18
19
# File 'lib/plux/reactor.rb', line 16

def register(socket)
  @newly_accepted << socket
  @nio.wakeup
end