Class: Nanoc::CLI::Commands::Compile::GCController Private
- Defined in:
- lib/nanoc/cli/commands/compile.rb
Overview
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.
Controls garbage collection so that it only occurs once every 20 items
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ GCController
constructor
private
A new instance of GCController.
- #start ⇒ Object private
- #stop ⇒ Object private
Methods inherited from Listener
Constructor Details
#initialize ⇒ GCController
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 GCController.
267 268 269 |
# File 'lib/nanoc/cli/commands/compile.rb', line 267 def initialize(*) @gc_count = 0 end |
Class Method Details
.enable_for?(_command_runner) ⇒ Boolean
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.
263 264 265 |
# File 'lib/nanoc/cli/commands/compile.rb', line 263 def self.enable_for?(_command_runner) !ENV.key?('TRAVIS') end |
Instance Method Details
#start ⇒ 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.
272 273 274 275 276 277 278 279 280 281 |
# File 'lib/nanoc/cli/commands/compile.rb', line 272 def start Nanoc::Int::NotificationCenter.on(:compilation_started) do |_rep| if @gc_count % 20 == 0 GC.enable GC.start GC.disable end @gc_count += 1 end end |
#stop ⇒ 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.
284 285 286 287 |
# File 'lib/nanoc/cli/commands/compile.rb', line 284 def stop super GC.enable end |