Class: Concurrent::Supervisor::WorkerCounts

Inherits:
Struct
  • Object
show all
Defined in:
lib/concurrent/supervisor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#specsObject

Returns the value of attribute specs

Returns:

  • (Object)

    the current value of specs



39
40
41
# File 'lib/concurrent/supervisor.rb', line 39

def specs
  @specs
end

#statusObject

Returns the value of attribute status.



40
41
42
# File 'lib/concurrent/supervisor.rb', line 40

def status
  @status
end

#supervisorsObject

Returns the value of attribute supervisors

Returns:

  • (Object)

    the current value of supervisors



39
40
41
# File 'lib/concurrent/supervisor.rb', line 39

def supervisors
  @supervisors
end

#workersObject

Returns the value of attribute workers

Returns:

  • (Object)

    the current value of workers



39
40
41
# File 'lib/concurrent/supervisor.rb', line 39

def workers
  @workers
end

Instance Method Details

#abendObject



51
# File 'lib/concurrent/supervisor.rb', line 51

def abend() @status.reduce(0){|x, s| x += (s.nil? ? 1 : 0) } end

#abortingObject



49
# File 'lib/concurrent/supervisor.rb', line 49

def aborting() @status.reduce(0){|x, s| x += (s == 'aborting' ? 1 : 0) } end

#activeObject



46
# File 'lib/concurrent/supervisor.rb', line 46

def active() sleeping + running + aborting end

#add(context) ⇒ Object



41
42
43
44
45
# File 'lib/concurrent/supervisor.rb', line 41

def add(context)
  self.specs += 1
  self.supervisors += 1 if context.type == :supervisor
  self.workers += 1 if context.type == :worker
end

#runningObject



48
# File 'lib/concurrent/supervisor.rb', line 48

def running() @status.reduce(0){|x, s| x += (s == 'run' ? 1 : 0) } end

#sleepingObject



47
# File 'lib/concurrent/supervisor.rb', line 47

def sleeping() @status.reduce(0){|x, s| x += (s == 'sleep' ? 1 : 0) } end

#stoppedObject



50
# File 'lib/concurrent/supervisor.rb', line 50

def stopped() @status.reduce(0){|x, s| x += (s == false ? 1 : 0) } end