Class: OnStomp::OpenURI::MessageQueue
- Inherits:
-
Object
- Object
- OnStomp::OpenURI::MessageQueue
- Defined in:
- lib/onstomp/open-uri/message_queue.rb
Overview
A simple synchronized message queue used to handle yielding MESSAGE frames to ClientExtensions#each blocks.
Instance Method Summary collapse
-
#initialize ⇒ MessageQueue
constructor
A new instance of MessageQueue.
-
#push(msg) ⇒ Object
(also: #<<)
Puts a new object into the queue.
-
#shift ⇒ Object
Waits until the queue contains at least one element, then takes it out and returns it.
Constructor Details
#initialize ⇒ MessageQueue
Returns a new instance of MessageQueue.
6 7 8 9 10 |
# File 'lib/onstomp/open-uri/message_queue.rb', line 6 def initialize @queue = [] @queue.extend MonitorMixin @empty_check = @queue.new_cond end |
Instance Method Details
#push(msg) ⇒ Object Also known as: <<
Puts a new object into the queue.
19 20 21 |
# File 'lib/onstomp/open-uri/message_queue.rb', line 19 def push msg put_in_queue :push, msg end |
#shift ⇒ Object
Waits until the queue contains at least one element, then takes it out and returns it.
14 15 16 |
# File 'lib/onstomp/open-uri/message_queue.rb', line 14 def shift take_from_queue :shift end |