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



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

def specs
  @specs
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#supervisorsObject

Returns the value of attribute supervisors

Returns:

  • (Object)

    the current value of supervisors



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

def supervisors
  @supervisors
end

#workersObject

Returns the value of attribute workers

Returns:

  • (Object)

    the current value of workers



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

def workers
  @workers
end

Instance Method Details

#abendObject



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

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

#abortingObject



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

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

#activeObject



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

def active() sleeping + running + aborting end

#add(context) ⇒ Object



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

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

#runningObject



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

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

#sleepingObject



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

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

#stoppedObject



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

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