Class: MultipleMan::ChannelMaintenance::GC::SweepCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/multiple_man/channel_maintenance/gc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, reaper) ⇒ SweepCommand

Returns a new instance of SweepCommand.



84
85
86
87
# File 'lib/multiple_man/channel_maintenance/gc.rb', line 84

def initialize(queue, reaper)
  @queue = queue
  @reaper = reaper
end

Instance Attribute Details

#queueObject (readonly)

Returns the value of attribute queue.



83
84
85
# File 'lib/multiple_man/channel_maintenance/gc.rb', line 83

def queue
  @queue
end

#reaperObject (readonly)

Returns the value of attribute reaper.



83
84
85
# File 'lib/multiple_man/channel_maintenance/gc.rb', line 83

def reaper
  @reaper
end

Instance Method Details

#execute(channels_by_thread) ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/multiple_man/channel_maintenance/gc.rb', line 89

def execute(channels_by_thread)
  channels_by_thread.each do |thread_id, channels|
    thing = ObjectSpace._id2ref(thread_id) rescue nil
    next if thing.kind_of?(Thread) && thing.alive?

    channels.each {|c| reaper.push(c)}
    queue << RemoveCommand.new(thread_id)
  end
end