class Nanoc::Core::CompilationPhases::Resume
Provides functionality for suspending and resuming item rep compilation (using fibers).
Constants
- DONE
Public Instance Methods
run(rep, is_outdated:) { || ... }
click to toggle source
# File lib/nanoc/core/compilation_phases/resume.rb, line 13 def run(rep, is_outdated:) fiber = fiber_for(rep, is_outdated: is_outdated) { yield } while fiber.alive? res = fiber.resume case res when Nanoc::Core::Errors::UnmetDependency Nanoc::Core::NotificationCenter.post(:compilation_suspended, rep, res.rep, res.snapshot_name) raise(res) when Proc fiber.resume(res.call) when DONE # ignore else raise Nanoc::Core::Errors::InternalInconsistency.new( "Fiber yielded object of unexpected type #{res.class}", ) end end end
Private Instance Methods
fiber_for(rep, is_outdated:) { || ... }
click to toggle source
# File lib/nanoc/core/compilation_phases/resume.rb, line 37 def fiber_for(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument @fibers ||= {} @fibers[rep] ||= Fiber.new do yield @fibers.delete(rep) DONE end @fibers[rep] end