Sha256: e3c348c59ef21be119f6318d1e96f2e55f56799fa4b00bf0812b688069348b7d

Contents?: true

Size: 1005 Bytes

Versions: 7

Compression:

Stored size: 1005 Bytes

Contents

require 'fiona7/prefetch/obj_prefetch'
require 'fiona7/prefetch/widget_resolver_prefetch'

require 'fiona7/widget_gc/sweep_strategies/factory'
require 'fiona7/widget_gc/marker'

module Fiona7
  module WidgetGc
    class GarbageCollector
      def initialize(object_id, mode)
        self.object_id = object_id
        self.mode = mode
        self.klass = Fiona7::WriteObj
      end

      def gc!
        if (sweep_strategy = SweepStrategies::Factory.for(self.mode, Fiona7.widget_gc_strategy))
          object          = Prefetch::ObjPrefetch.new(self.klass, [self.object_id]).find_one(self.object_id)
          widget_resolver = Prefetch::WidgetResolverPrefetch.new(self.klass, [object]).widget_resolver(object)
          marker          = Marker.new(object, widget_resolver)

          if marker.garbage?
            sweep_strategy.new(object, widget_resolver).sweep!(marker.garbage)
          end
        end
      end

      protected
      attr_accessor :object_id, :mode, :klass
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/widget_gc/garbage_collector.rb
infopark_fiona7-1.6.1.1.1 lib/fiona7/widget_gc/garbage_collector.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/widget_gc/garbage_collector.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/widget_gc/garbage_collector.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/widget_gc/garbage_collector.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/widget_gc/garbage_collector.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/widget_gc/garbage_collector.rb