Module: Qwirk::Adapter::InMemory::Factory
- Defined in:
- lib/qwirk/adapter/in_memory/factory.rb
Class Method Summary collapse
- .get_publisher_queue(queue_name, topic_name) ⇒ Object
- .get_worker_queue(worker_name, queue_name, topic_name, queue_max_size) ⇒ Object
- .init ⇒ Object
Class Method Details
.get_publisher_queue(queue_name, topic_name) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/qwirk/adapter/in_memory/factory.rb', line 28 def get_publisher_queue(queue_name, topic_name) if queue_name @queue_hash_mutex.synchronize do return @queue_hash[queue_name] ||= Queue.new(queue_name) end else @topic_hash_mutex.synchronize do return @topic_hash[topic_name] ||= Topic.new(topic_name) end end end |
.get_worker_queue(worker_name, queue_name, topic_name, queue_max_size) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/qwirk/adapter/in_memory/factory.rb', line 13 def get_worker_queue(worker_name, queue_name, topic_name, queue_max_size) if queue_name @queue_hash_mutex.synchronize do queue = @queue_hash[queue_name] ||= Queue.new(queue_name) queue.max_size = queue_max_size return queue end else @topic_hash_mutex.synchronize do topic = @topic_hash[topic_name] ||= Topic.new(topic_name) return topic.get_worker_queue(worker_name, queue_max_size) end end end |
.init ⇒ Object
6 7 8 9 10 11 |
# File 'lib/qwirk/adapter/in_memory/factory.rb', line 6 def init @queue_hash = {} @topic_hash = {} @queue_hash_mutex = Mutex.new @topic_hash_mutex = Mutex.new end |