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.
38 39 40 |
# File 'app/models/solid_queue/semaphore.rb', line 38 def initialize(job) @job = job end |
Class Method Details
.signal_all(jobs) ⇒ Object
34 35 36 |
# File 'app/models/solid_queue/semaphore.rb', line 34 def self.signal_all(jobs) Semaphore.where(key: jobs.map(&:concurrency_key)).update_all("value = value + 1") end |
Instance Method Details
#signal ⇒ Object
50 51 52 |
# File 'app/models/solid_queue/semaphore.rb', line 50 def signal attempt_increment end |
#wait ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/models/solid_queue/semaphore.rb', line 42 def wait if semaphore = Semaphore.find_by(key: key) semaphore.value > 0 && attempt_decrement else attempt_creation end end |