Class: Nanoc::CLI::Commands::Compile::GCController
- Inherits:
-
Listener
- Object
- Listener
- Nanoc::CLI::Commands::Compile::GCController
- Defined in:
- lib/nanoc/cli/commands/compile.rb
Overview
Controls garbage collection so that it only occurs once every 20 items
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (GCController) initialize(_params = {})
constructor
A new instance of GCController.
-
- (Object) start
-
- (Object) stop
Constructor Details
- (GCController) initialize(_params = {})
Returns a new instance of GCController
258 259 260 |
# File 'lib/nanoc/cli/commands/compile.rb', line 258 def initialize(_params = {}) @gc_count = 0 end |
Class Method Details
+ (Boolean) enable_for?(_command_runner)
254 255 256 |
# File 'lib/nanoc/cli/commands/compile.rb', line 254 def self.enable_for?(_command_runner) !ENV.key?('TRAVIS') end |
Instance Method Details
- (Object) start
263 264 265 266 267 268 269 270 271 272 |
# File 'lib/nanoc/cli/commands/compile.rb', line 263 def start Nanoc::NotificationCenter.on(:compilation_started) do |_rep| if @gc_count % 20 == 0 GC.enable GC.start GC.disable end @gc_count += 1 end end |
- (Object) stop
275 276 277 278 |
# File 'lib/nanoc/cli/commands/compile.rb', line 275 def stop super GC.enable end |