timeout.rb: watcher thread name

* lib/timeout.rb (Timeout#timeout): set watcher thread name to
  caller location for debugging.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-12-18 15:46:50 +00:00
Родитель 70bf86a711
Коммит d660e06f28
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -73,11 +73,13 @@ module Timeout
def timeout(sec, klass = nil) #:yield: +sec+
return yield(sec) if sec == nil or sec.zero?
message = "execution expired".freeze
from = "from #{caller_locations(1, 1)[0]}" if $DEBUG
e = Error
bl = proc do |exception|
begin
x = Thread.current
y = Thread.start {
Thread.current.name = from
begin
sleep sec
rescue => e