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.



387
388
389
390
391
# File 'lib/fluent/process.rb', line 387

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

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


412
413
414
# File 'lib/fluent/process.rb', line 412

def finished?
  @finished
end

#stopObject



401
402
403
404
405
406
407
408
409
410
# File 'lib/fluent/process.rb', line 401

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



393
394
395
396
397
398
399
# File 'lib/fluent/process.rb', line 393

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