mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/monitor.rb: handle exceptions correctly. Thanks, Gennady
Bystritsky. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
45b46d78fa
commit
764722dc27
2 changed files with 25 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Oct 11 10:19:39 2003 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/monitor.rb: handle exceptions correctly. Thanks, Gennady
|
||||||
|
Bystritsky.
|
||||||
|
|
||||||
Fri Oct 10 07:50:54 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Oct 10 07:50:54 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (is_defined): inheritance line adjustment as like as
|
* eval.c (is_defined): inheritance line adjustment as like as
|
||||||
|
|
|
@ -130,10 +130,14 @@ module MonitorMixin
|
||||||
t.wakeup if t
|
t.wakeup if t
|
||||||
@waiters.push(Thread.current)
|
@waiters.push(Thread.current)
|
||||||
|
|
||||||
begin
|
preserved_exceptions = []
|
||||||
Thread.stop
|
while true
|
||||||
rescue Timeout
|
begin
|
||||||
ensure
|
Thread.stop
|
||||||
|
rescue Timeout
|
||||||
|
rescue Exception => exception
|
||||||
|
preserved_exceptions << exception
|
||||||
|
end
|
||||||
Thread.critical = true
|
Thread.critical = true
|
||||||
if timeout && timeout_thread.alive?
|
if timeout && timeout_thread.alive?
|
||||||
Thread.kill(timeout_thread)
|
Thread.kill(timeout_thread)
|
||||||
|
@ -141,15 +145,17 @@ module MonitorMixin
|
||||||
if @waiters.include?(Thread.current) # interrupted?
|
if @waiters.include?(Thread.current) # interrupted?
|
||||||
@waiters.delete(Thread.current)
|
@waiters.delete(Thread.current)
|
||||||
end
|
end
|
||||||
while @monitor.mon_owner &&
|
|
||||||
@monitor.mon_owner != Thread.current
|
break if @monitor.mon_owner.nil? or @monitor.mon_owner == Thread.current
|
||||||
@monitor.mon_waiting_queue.push(Thread.current)
|
@monitor.mon_waiting_queue.delete(Thread.current)
|
||||||
Thread.stop
|
@monitor.mon_waiting_queue.push(Thread.current)
|
||||||
Thread.critical = true
|
end
|
||||||
end
|
@monitor.mon_owner = Thread.current
|
||||||
@monitor.mon_owner = Thread.current
|
@monitor.mon_count = count
|
||||||
@monitor.mon_count = count
|
Thread.critical = false
|
||||||
Thread.critical = false
|
|
||||||
|
unless preserved_exceptions.empty?
|
||||||
|
raise preserved_exceptions.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -232,6 +238,7 @@ module MonitorMixin
|
||||||
def mon_enter
|
def mon_enter
|
||||||
Thread.critical = true
|
Thread.critical = true
|
||||||
while mon_owner != nil && mon_owner != Thread.current
|
while mon_owner != nil && mon_owner != Thread.current
|
||||||
|
mon_entering_queue.delete(Thread.current)
|
||||||
mon_entering_queue.push(Thread.current)
|
mon_entering_queue.push(Thread.current)
|
||||||
Thread.stop
|
Thread.stop
|
||||||
Thread.critical = true
|
Thread.critical = true
|
||||||
|
|
Loading…
Reference in a new issue