Sha256: 73724d5af18a0c1fa312c60927fe157fcca19ede851a32b11d35c42112c98f6e
Contents?: true
Size: 1.25 KB
Versions: 7
Compression:
Stored size: 1.25 KB
Contents
require 'fiona7/widget_object_id_collector' require 'fiona7/widgetlist_enumerator' module Fiona7 module WidgetGc class Marker def initialize(object, widget_resolver) self.object = object self.widgets = widget_resolver.all self.mark end def garbage self.available - self.referenced end def garbage? self.garbage.any? end attr_reader :object, :widgets, :available, :referenced protected attr_writer :object, :widgets, :available, :referenced def mark ref_from_obj = self.object_ids_of_widgets(object) ref_from_widgets = widgets.map do |widget_object| # TODO: check if widget_object referenced from object self.object_ids_of_widgets(widget_object) end.flatten # TODO: maybe use widgets.map(&:id) instead? self.available = Set.new(WidgetObjectIdCollector.new(self.object.attr_values["X_widget_pool"]).call).freeze self.referenced = Set.new(ref_from_obj + ref_from_widgets).freeze end def object_ids_of_widgets(object) WidgetlistEnumerator.new(object).to_enum.map {|attr_name, attr_value| WidgetObjectIdCollector.new(attr_value).call }.flatten end end end end
Version data entries
7 entries across 7 versions & 1 rubygems