class Procrastinate::SpawnStrategy::Throttled

A dispatcher strategy that throttles tasks starting and ensures that no more than limit processes run concurrently.

Attributes

current[R]
limit[R]

Public Class Methods

new(limit) click to toggle source

Client thread

Calls superclass method
# File lib/procrastinate/spawn_strategy/throttled.rb, line 9
def initialize(limit)
  super()
  
  @limit = limit
  @current = 0
end

Public Instance Methods

notify_dead() click to toggle source
# File lib/procrastinate/spawn_strategy/throttled.rb, line 25
def notify_dead
  @current -= 1
  warn "Throttled reports more deaths than births?!" if current < 0
end
notify_spawn() click to toggle source
# File lib/procrastinate/spawn_strategy/throttled.rb, line 20
def notify_spawn
  @current += 1
  warn "Throttled reports too many births!" if current > limit
end
should_spawn?() click to toggle source
# File lib/procrastinate/spawn_strategy/throttled.rb, line 16
def should_spawn?
  current < limit
end