Module: RudeQ::PessimisticLock
- Defined in:
- lib/rude_q.rb
Overview
uses standard ActiveRecord :lock => true this will invoke a lock on the particular queue
eg. daemon1: RudeQueue.get(:abc)
daemon2: RudeQueue.get(:abc) - will have to wait for daemon1 to finish
daemon3: RudeQueue.get(:def) - will avoid the lock
Class Method Summary collapse
Class Method Details
.fetch_with_lock(klass, qname) ⇒ Object
:nodoc:
169 170 171 172 173 174 175 176 177 |
# File 'lib/rude_q.rb', line 169 def fetch_with_lock(klass, qname) # :nodoc: klass.transaction do record = klass.find(:first, :conditions => {:queue_name => qname, :processed => false}, :lock => true, :order => "id ASC", :limit => 1) return yield(record) end end |