Class: Wakame::CommandQueue
- Inherits:
-
Object
- Object
- Wakame::CommandQueue
- Defined in:
- lib/wakame/command_queue.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
readonly
Returns the value of attribute master.
Instance Method Summary collapse
- #deq_cmd ⇒ Object
- #enq_result(res) ⇒ Object
-
#initialize(master) ⇒ CommandQueue
constructor
A new instance of CommandQueue.
- #send_cmd(cmd) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(master) ⇒ CommandQueue
Returns a new instance of CommandQueue.
9 10 11 12 13 14 15 16 |
# File 'lib/wakame/command_queue.rb', line 9 def initialize(master) @master = master @queue = Queue.new @result_queue = Queue.new DRb.start_service(Wakame.config.drb_command_server_uri, self) #@drb_server = DRb.start_drbserver(Wakame.config.drb_command_server_uri, self) end |
Instance Attribute Details
#master ⇒ Object (readonly)
Returns the value of attribute master.
7 8 9 |
# File 'lib/wakame/command_queue.rb', line 7 def master @master end |
Instance Method Details
#deq_cmd ⇒ Object
23 24 25 |
# File 'lib/wakame/command_queue.rb', line 23 def deq_cmd() @queue.deq end |
#enq_result(res) ⇒ Object
27 28 29 |
# File 'lib/wakame/command_queue.rb', line 27 def enq_result(res) @result_queue.enq(res) end |
#send_cmd(cmd) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wakame/command_queue.rb', line 31 def send_cmd(cmd) begin #cmd = Marshal.load(cmd) @queue.enq(cmd) ED.fire_event(Event::CommandReceived.new(cmd)) return @result_queue.deq() rescue => e Wakame.log.error("#{self.class}:") Wakame.log.error(e) end end |
#shutdown ⇒ Object
18 19 20 21 |
# File 'lib/wakame/command_queue.rb', line 18 def shutdown DRb.stop_service() #@drb_server.stop_service() end |