diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-14 14:51:42 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-14 14:51:42 +0000 |
commit | 6c6a24826c5fda68e04e71ac17620b0e70bca265 (patch) | |
tree | c2692457fbae375c8a38fd64a90a852365e331fc /lib/thread.rb | |
parent | 1a760a6f76e5b2fad343fce10ebf831fe22286b4 (diff) |
* enum.c (enum_min_by): new method Enum#min_by. added Enum#max_by
as well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/thread.rb')
-rw-r--r-- | lib/thread.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/thread.rb b/lib/thread.rb index 8b27356c48..a069c4680a 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -69,7 +69,7 @@ class Mutex # Returns +true+ if this lock is currently held by some thread. # def locked? - @locked + @locked && true end # @@ -80,7 +80,7 @@ class Mutex result = false Thread.critical = true unless @locked - @locked = true + @locked = Thread.current result = true end Thread.critical = false @@ -92,10 +92,13 @@ class Mutex # def lock while (Thread.critical = true; @locked) + if @locked == Thread.current + raise ThreadError, "deadlock; recursive locking" + end @waiting.push Thread.current Thread.stop end - @locked = true + @locked = Thread.current Thread.critical = false self end |