Class: Skylight::GC Private
- Includes:
- Util::Logging
- Defined in:
- lib/skylight/gc.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Window
Constant Summary collapse
- METHODS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ :enable, :total_time ]
- TH_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:SK_GC_CURR_WINDOW
- MAX_COUNT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1000
- MAX_TIME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
30_000_000
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
Instance Method Summary collapse
- #enable ⇒ Object private
-
#initialize(config, profiler) ⇒ GC
constructor
private
A new instance of GC.
- #release(win) ⇒ Object private
- #track ⇒ Object private
- #update ⇒ Object private
Methods included from Util::Logging
#debug, #error, #info, #log, #t, #trace, trace?, #warn
Constructor Details
#initialize(config, profiler) ⇒ GC
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GC.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/skylight/gc.rb', line 15 def initialize(config, profiler) @listeners = [] @config = config @lock = Mutex.new @time = 0 if METHODS.all? { |m| profiler.respond_to?(m) } @profiler = profiler @time = @profiler.total_time else debug "disabling GC profiling" end end |
Instance Attribute Details
#config ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/skylight/gc.rb', line 13 def config @config end |
Instance Method Details
#enable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/skylight/gc.rb', line 29 def enable @profiler.enable if @profiler end |
#release(win) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 60 61 |
# File 'lib/skylight/gc.rb', line 57 def release(win) @lock.synchronize do @listeners.delete(win) end end |
#track ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/skylight/gc.rb', line 33 def track unless @profiler win = Window.new(nil) else win = Window.new(self) @lock.synchronize do __update @listeners << win # Cleanup any listeners that might have leaked until @listeners[0].time < MAX_TIME @listeners.shift end if @listeners.length > MAX_COUNT @listeners.shift end end end win end |
#update ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 |
# File 'lib/skylight/gc.rb', line 63 def update @lock.synchronize do __update end nil end |