Class: OnStomp::OpenURI::MessageQueue

Inherits:
Object
  • Object
show all
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)

Constructor Details

- (MessageQueue) initialize

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

- (Object) push(msg) 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

- (Object) shift

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