Module: Ramaze::Helper::Thread

Defined in:
lib/ramaze/helper/thread.rb

Instance Method Summary collapse

Instance Method Details

#thread(&block) ⇒ Object

The thread method executes the specified block in a new thread.

Parameters:

  • block (Block)

    The block that contains the code that will be executed in the new thread.



13
14
15
16
17
18
19
20
21
22
# File 'lib/ramaze/helper/thread.rb', line 13

def thread &block
  parent_thread = Thread.current
  Thread.new do
    begin
      block.call
    rescue Exception => e
      parent_thread.raise(e)
    end
  end
end