Class: FreeMessageQueue::SyncronizedQueue
- Inherits:
-
LinkedQueue
- Object
- BaseQueue
- LinkedQueue
- FreeMessageQueue::SyncronizedQueue
- Defined in:
- lib/fmq/queues/syncronized.rb
Overview
The SyncronizedQueue implements a little wrapper around the LinkedQueue to make it thread safe
queue_manager = FreeMessageQueue::QueueManager.new(true) do
setup_queue "/fmq_test/test1" do |q|
q. = 1000000
q.max_size = 10.kb
end
end
Constant Summary
Constants inherited from BaseQueue
Instance Attribute Summary
Attributes inherited from BaseQueue
#bytes, #manager, #max_messages, #max_size, #size
Instance Method Summary collapse
-
#initialize(manager) ⇒ SyncronizedQueue
constructor
A new instance of SyncronizedQueue.
-
#poll ⇒ Object
Returns one item from the queue.
-
#put(message) ⇒ Object
Puts one message to the queue.
Methods inherited from LinkedQueue
Methods inherited from BaseQueue
Constructor Details
#initialize(manager) ⇒ SyncronizedQueue
Returns a new instance of SyncronizedQueue.
34 35 36 37 |
# File 'lib/fmq/queues/syncronized.rb', line 34 def initialize(manager) super(manager) @semaphore = Mutex.new end |
Instance Method Details
#poll ⇒ Object
Returns one item from the queue
40 41 42 43 44 |
# File 'lib/fmq/queues/syncronized.rb', line 40 def poll() @semaphore.synchronize { super } end |
#put(message) ⇒ Object
Puts one message to the queue
47 48 49 50 51 |
# File 'lib/fmq/queues/syncronized.rb', line 47 def put() @semaphore.synchronize { super() } end |