Dan,
I often create a new thread like this:
Thread.new Thread.current do |parentThread|
parentThread[:foo] = :bar
end
It doesn't seem tedious to me and it makes the argument
passing explicit. If you want an implicit parentThread as
the last argument,
you can easily implement it something like this:
class Thread
def self.create(*args, &block)
new(*(args<<Thread.current), &block)
end
end
You could even alias new to new_original and
use this technique to replace Thread.new, but
I would not recommend that.
- brent
Hi,
I find this idiom bit tedious:
Thread.new{ Thread.current['foo'] = 'bar' }
What about always yielding the current thread as the last argument?
# With no arguments
Thread.new{ |curr| curr['foo'] = 'bar' }
# With some arguments
Thread.new(x,y){ |x,y,curr| curr['foo'] = 'bar' }
...
--
View this message in context: http://www.nabble.com/Idea%3A-always-yield-current-thread-to-Thread.new-tf4950503.html#a14179091
Sent from the ruby-core mailing list archive at Nabble.com.