Module: Daemon::Utils::EM

Defined in:
lib/onapp/engine/utils/em.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) run



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/onapp/engine/utils/em.rb', line 8

def run
  if !::EM.reactor_running?
    stop

    Thread.new { ::EM.run }

    Timeout.timeout(5) do
      sleep 0.01 until ::EM.reactor_running?
    end
  end
end

+ (Object) stop



20
21
22
# File 'lib/onapp/engine/utils/em.rb', line 20

def stop
  ::EM.reactor_running? && thread.kill
end

+ (Object) thread



24
25
26
# File 'lib/onapp/engine/utils/em.rb', line 24

def thread
  ::EM.reactor_thread
end