aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 01:40:53 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 01:40:53 +0000
commit880eeb3d5a7847a4aa091b2bea470761945e5f6b (patch)
tree9e5660ba720d16f54167e2bef4f48dfc5ddbf7be /lib
parent9f6a9a508616cfc36d32ca388070efbfeca0ed36 (diff)
downloadruby-880eeb3d5a7847a4aa091b2bea470761945e5f6b.tar.gz
Add MonitorMinx#mon_locked? and #mon_owned? to check states of objects
Patched by Satoshi "Moris" Tagomori <tagomoris@gmail.com>. [Fix GH-1699] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/monitor.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 3ded0b3658..cbc1a13a21 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -204,6 +204,20 @@ module MonitorMixin
end
#
+ # Returns true if this monitor is locked by any thread
+ #
+ def mon_locked?
+ @mon_mutex.locked?
+ end
+
+ #
+ # Returns true if this monitor is locked by current thread.
+ #
+ def mon_owned?
+ @mon_mutex.locked? && @mon_owner == Thread.current
+ end
+
+ #
# Enters exclusive section and executes the block. Leaves the exclusive
# section automatically when the block exits. See example under
# +MonitorMixin+.