3 # $Release Version: 3.0$
5 # $Date: 1998/02/27 04:28:57 $
6 # Original from mutex.rb
7 # by Keiju ISHITSUKA(keiju@ishitsuka.com)
9 # patched by akira yamada
14 # Extend an object and use it like a Mutex object:
16 # require "mutex_m.rb"
21 # Or, include Mutex_m in a class to have its instances behave like a Mutex
32 def Mutex_m.define_aliases(cl)
34 alias locked? mu_locked?
36 alias unlock mu_unlock
37 alias try_lock mu_try_lock
38 alias synchronize mu_synchronize
42 def Mutex_m.append_features(cl)
44 define_aliases(cl) unless cl.instance_of?(Module)
47 def Mutex_m.extend_object(obj)
53 unless (defined? locked? and
58 Mutex_m.define_aliases(class<<self;self;end)
79 Thread.critical = true
84 Thread.critical = false
89 while (Thread.critical = true; @mu_locked)
90 @mu_waiting.push Thread.current
94 Thread.critical = false
99 return unless @mu_locked
100 Thread.critical = true
104 Thread.critical = false
118 def initialize(*args)