Class: Ffmprb::Util::Thread

Inherits:
Thread
  • Object
show all
Defined in:
lib/ffmprb/util/thread.rb

Overview

NOTE doesn’t have specs (and not too proud about it)

Direct Known Subclasses

Reader

Instance Method Summary collapse

Constructor Details

#initialize(name = "some", &blk) ⇒ Thread



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ffmprb/util/thread.rb', line 8

def initialize(name="some", &blk)
  super() do
    begin
      Ffmprb.logger.debug "#{name} thread launched"
      blk.call
      Ffmprb.logger.debug "#{name} thread done"
    rescue Exception
      Ffmprb.logger.warn "#{$!.class} caught in a #{name} thread (hidden): #{$!.message}\nBacktrace:\n\t#{$!.backtrace.join("\n\t")}"
      cause = $!
      Ffmprb.logger.warn "...caused by #{cause.class}: #{cause.message}\nBacktrace:\n\t#{cause.backtrace.join("\n\t")}" while
        cause = cause.cause
      raise
    end
  end
end