Skip to content

Commit

Permalink
Thread.detect_outermost_recursion: Fix error spotted by Evan and make…
Browse files Browse the repository at this point in the history
… much nicer
  • Loading branch information
marcandre committed Jan 12, 2010
1 parent ae37c72 commit 6276059
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions kernel/common/thread.rb
Expand Up @@ -337,23 +337,16 @@ def self.detect_recursion(obj, paired_obj = undefined)
# levels (using a throw)

def self.detect_outermost_recursion(obj, paired_obj=undefined, &block)
objects = current.recursive_objects
if objects[:__detect_outermost_recursion__] # then not outermost
if Rubinius::ThrownValue.available? :__detect_outermost_recursion__
if detect_recursion(obj, paired_obj, &block)
throw :__detect_outermost_recursion__, :__detect_outermost_recursion__
throw :__detect_outermost_recursion__, true
end
false
else
begin
objects[:__detect_outermost_recursion__] = true # signal that there is an outermost
r = catch(:__detect_outermost_recursion__) do
throw objects, objects if detect_recursion(obj, paired_obj, &block)
end
return true if r == :__detect_outermost_recursion__
ensure
objects[:__detect_outermost_recursion__] = false
catch :__detect_outermost_recursion__ do
detect_recursion(obj, paired_obj, &block)
end
end
false
end

class Context
Expand Down

0 comments on commit 6276059

Please sign in to comment.