lib/donaghy/adapters/message_queue/sqs.rb
# the reason the below is a little weird (with basically repeated code inside of a guard)
# is it's about not entering the guard.synchronize unless you need to...
# after the queue has been cached, no threads need to regulate their access to the queue,
# so they can just pull it out of the hash without synchronizing
# in the case where the queue hasn't been cached, you need to repeat that return inside of
# the synchronization in case two threads have ended up at the guard.
the reason the below is a little weird (with basically repeated code inside of a guard)
is it's about not entering the guard.synchronize unless you need to
after the queue has been cached, no threads need to regulate their access to the queue,
so they can just pull it out of the hash without synchronizing
in the case where the queue hasn't been cached, you need to repeat that return inside of
the synchronization in case two threads have ended up at the guard.
the reason the below is a little weird ( with basically repeated code inside of a guard ) is it ' s about not entering the guard . synchronize unless you need to after the queue has been cached no threads need to regulate their access to the queue so they can just pull it out of the hash without synchronizing in the case where the queue hasn ' t been cached you need to repeat that return inside of the synchronization in case two threads have ended up at the guard .
def find_by_name(queue_name)
        if queue_hash[queue_name]
          queue_hash[queue_name]
        else
          guard.synchronize do
            if queue_hash[queue_name]
              queue_hash[queue_name]
            else
              queue_hash[queue_name] = SqsQueue.new(queue_name, sqs: sqs)
            end
          end
        end
      end
def find_by_name ( queue_name ) if queue_hash [ queue_name ] queue_hash [ queue_name ] else guard . synchronize do if queue_hash [ queue_name ] queue_hash [ queue_name ] else queue_hash [ queue_name ] = SqsQueue . new ( queue_name , sqs : sqs ) end end end end
the reason the below is a little weird (with basically repeated code inside of a guard)
is it's about not entering the guard.synchronize unless you need to...
after the queue has been cached, no threads need to regulate their access to the queue,
so they can just pull it out of the hash without synchronizing
in the case where the queue hasn't been cached, you need to repeat that return inside of
the synchronization in case two threads have ended up at the guard.
the reason the below is a little weird ( with basically repeated code inside of a guard ) is it ' s about not entering the guard . synchronize unless you need to ... after the queue has been cached no threads need to regulate their access to the queue so they can just pull it out of the hash without synchronizing in the case where the queue hasn ' t been cached you need to repeat that return inside of the synchronization in case two threads have ended up at the guard .
queue_name
<not_specific>