3 # $Release Version: 3.0$
6 # Original from mutex.rb
7 # by Keiju ISHITSUKA(keiju@ishitsuka.com)
9 # patched by akira yamada
15 # Extend an object and use it like a Mutex object:
17 # require "mutex_m.rb"
22 # Or, include Mutex_m in a class to have its instances behave like a Mutex
35 def Mutex_m.define_aliases(cl)
37 alias locked? mu_locked?
39 alias unlock mu_unlock
40 alias try_lock mu_try_lock
41 alias synchronize mu_synchronize
45 def Mutex_m.append_features(cl)
47 define_aliases(cl) unless cl.instance_of?(Module)
50 def Mutex_m.extend_object(obj)
56 unless (defined? locked? and
61 Mutex_m.define_aliases(class<<self;self;end)
68 @mu_mutex.synchronize { yield }
92 @mu_mutex = ::Mutex.new