Class: Fluent::DetachProcessImpl::FinishWait

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/process.rb

Instance Method Summary collapse

Constructor Details

#initializeFinishWait

Returns a new instance of FinishWait.



383
384
385
386
387
# File 'lib/fluent/process.rb', line 383

def initialize
  @finished = false
  @mutex = Mutex.new
  @cond = ConditionVariable.new
end

Instance Method Details

#finished?Boolean

Returns:



408
409
410
# File 'lib/fluent/process.rb', line 408

def finished?
  @finished
end

#stopObject



397
398
399
400
401
402
403
404
405
406
# File 'lib/fluent/process.rb', line 397

def stop
  return if @finished
  @finished = true
  # Creating new thread due to mutex can't lock in main thread during trap context
  Thread.new {
    @mutex.synchronize do
      @cond.broadcast
    end
  }.run
end

#waitObject



389
390
391
392
393
394
395
# File 'lib/fluent/process.rb', line 389

def wait
  @mutex.synchronize do
    until @finished
      @cond.wait(@mutex, 1.0)
    end
  end
end