Module: EventMachine

Defined in:
lib/foxbat.rb,
lib/em/timer.rb,
lib/eventmachine.rb,
lib/em/connection.rb,
lib/em/periodic_timer.rb

Defined Under Namespace

Classes: Connection, PeriodicTimer, Timer

Class Method Summary collapse

Class Method Details

.epollObject

We’re on the JVM- this does nothing!



17
# File 'lib/eventmachine.rb', line 17

def self.epoll; end

.executorObject



33
34
35
# File 'lib/eventmachine.rb', line 33

def self.executor
  @@threadpool
end

.kqueueObject



18
# File 'lib/eventmachine.rb', line 18

def self.kqueue; end

.run(blk = nil, tail = nil, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/eventmachine.rb', line 20

def self.run(blk=nil, tail=nil, &block)    
  @@threadpool = Executors.newCachedThreadPool

  block.call

  @@threadpool.awaitTermination(Long::MAX_VALUE, TimeUnit::SECONDS)
end

.start_server(host, port = nil, handler = nil, *args, &block) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/eventmachine.rb', line 7

def self.start_server host, port=nil, handler=nil, *args, &block
  s = Foxbat::Server.new(host, port, handler, args.first || {}, block)

  @@servers ||= []
  @@servers << s

  s.start(@@threadpool)
end

.stopObject



28
29
30
31
# File 'lib/eventmachine.rb', line 28

def self.stop
  @@servers.each { |s| s.stop } unless @@servers.nil?
  @@threadpool.shutdownNow
end