Class: EventMachine::PosixMQ::Watcher

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/em-posixmq.rb

Instance Method Summary collapse

Constructor Details

#initialize(posix_mq) ⇒ Watcher

Returns a new instance of Watcher.



11
12
13
14
# File 'lib/em-posixmq.rb', line 11

def initialize posix_mq
  @posix_mq = posix_mq
  @posix_mq.nonblock = true
end

Instance Method Details

#notify_readableObject



16
17
18
19
20
# File 'lib/em-posixmq.rb', line 16

def notify_readable
  # POSIX_MQ#tryreceive returns nil in case there is nothing to read.
  message, priority = @posix_mq.tryreceive
  receive_message message, priority if message
end

#receive_message(message, priority) ⇒ Object

This method must be defined in the user’s class inherinting this one.



23
24
25
# File 'lib/em-posixmq.rb', line 23

def receive_message message, priority
  puts "EM::PosixMQ::Watcher#receive_message #{message.inspect}, #{priority.inspect}"
end