Class: Thread

Inherits:
Object show all
Defined in:
lib/ramaze/snippets/thread/into.rb

Overview

Extensions for Thread

Class Method Summary collapse

Class Method Details

.into(*args) ⇒ Object

Copy all thread variables into the new thread



9
10
11
12
13
14
15
16
17
# File 'lib/ramaze/snippets/thread/into.rb', line 9

def self.into *args
  Thread.new(Thread.current, *args) do |thread, *args|
    thread.keys.each do |k|
      Thread.current[k] = thread[k] unless k.to_s =~ /^__/
    end

    yield(*args)
  end
end