Class: Dharma::ThreadExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/dharma/thread_executor.rb

Instance Method Summary collapse

Constructor Details

#initializeThreadExecutor

Returns a new instance of ThreadExecutor.



3
4
# File 'lib/dharma/thread_executor.rb', line 3

def initialize
end

Instance Method Details

#execute(work) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/dharma/thread_executor.rb', line 6

def execute(work)
  Thread.new(work) do |work|
    begin
      work.call
    rescue Exception => e
      report_failure(e)
    end
  end
end

#report_failure(exception) ⇒ Object



16
17
18
# File 'lib/dharma/thread_executor.rb', line 16

def report_failure(exception)
  puts "Dharma: ThreadExecutor failure: #{exception.message} (#{exception.class})\n\t#{exception.backtrace.join("\n\t")}"
end