Class: SolidQueue::Semaphore::Proxy
- Inherits:
-
Object
- Object
- SolidQueue::Semaphore::Proxy
- Defined in:
- app/models/solid_queue/semaphore.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(job) ⇒ Proxy
constructor
A new instance of Proxy.
- #signal ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(job) ⇒ Proxy
Returns a new instance of Proxy.
27 28 29 |
# File 'app/models/solid_queue/semaphore.rb', line 27 def initialize(job) @job = job end |
Class Method Details
.signal_all(jobs) ⇒ Object
23 24 25 |
# File 'app/models/solid_queue/semaphore.rb', line 23 def self.signal_all(jobs) Semaphore.where(key: jobs.map(&:concurrency_key)).update_all("value = value + 1") end |
Instance Method Details
#signal ⇒ Object
39 40 41 |
# File 'app/models/solid_queue/semaphore.rb', line 39 def signal attempt_increment end |
#wait ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/models/solid_queue/semaphore.rb', line 31 def wait if semaphore = Semaphore.find_by(key: key) semaphore.value > 0 && attempt_decrement else attempt_creation end end |