Class: 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
-
#initialize ⇒ GCController
constructor
A new instance of GCController.
-
#start ⇒ Object
-
#stop ⇒ Object
Constructor Details
#initialize ⇒ GCController
Returns a new instance of GCController
250 251 252 |
# File 'lib/nanoc/cli/commands/compile.rb', line 250 def initialize(*) @gc_count = 0 end |
Class Method Details
.enable_for?(_command_runner) ⇒ Boolean
246 247 248 |
# File 'lib/nanoc/cli/commands/compile.rb', line 246 def self.enable_for?(_command_runner) !ENV.key?('TRAVIS') end |
Instance Method Details
#start ⇒ Object
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/nanoc/cli/commands/compile.rb', line 255 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
267 268 269 270 |
# File 'lib/nanoc/cli/commands/compile.rb', line 267 def stop super GC.enable end |