Class: Nanoc::Core::CompilationPhases::Write::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/core/compilation_phases/write.rb

Instance Method Summary collapse

Constructor Details

#initialize(queue:, compiled_content_store:) ⇒ Worker

Returns a new instance of Worker.



10
11
12
13
# File 'lib/nanoc/core/compilation_phases/write.rb', line 10

def initialize(queue:, compiled_content_store:)
  @queue = queue
  @compiled_content_store = compiled_content_store
end

Instance Method Details

#joinObject



28
29
30
# File 'lib/nanoc/core/compilation_phases/write.rb', line 28

def join
  @thread.join
end

#startObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nanoc/core/compilation_phases/write.rb', line 15

def start
  @thread = Thread.new do
    Thread.current.abort_on_exception = true
    Thread.current.priority = -1 # schedule I/O work ASAP

    writer = Nanoc::Core::ItemRepWriter.new

    while rep = @queue.pop # rubocop:disable Lint/AssignmentInCondition
      writer.write_all(rep, @compiled_content_store)
    end
  end
end