Module: EventMachine::PosixMQ

Defined in:
lib/em-posixmq/errors.rb,
lib/em-posixmq/version.rb,
lib/em-posixmq.rb

Defined Under Namespace

Classes: Error, Watcher

Constant Summary collapse

VERSION =
"0.2.3"

Class Method Summary collapse

Class Method Details

.run(posix_mq, handler) ⇒ Object

Raises:

  • (::EM::PosixMQ::Error)


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/em-posixmq.rb', line 28

def self.run posix_mq, handler
  raise ::EM::PosixMQ::Error, "EventMachine is not running" unless ::EM.reactor_running?

  raise ::EM::PosixMQ::Error, "`posix_mq' argument must be a POSIX_MQ instance" unless
    posix_mq.is_a? ::POSIX_MQ
    
  conn = ::EM.watch posix_mq.to_io, handler, posix_mq
  conn.notify_readable = true

  return conn
end