Module
mutex_m.rb
When ‘mutex_m’ is required, any object that extends or includes Mutex_m
will be treated like a Mutex
.
Start by requiring the standard library Mutex_m
:
require "mutex_m.rb"
From here you can extend an object with Mutex
instance methods:
obj = Object.new obj.extend Mutex_m
Or mixin Mutex_m
into your module to your class inherit Mutex
instance methods — remember to call super() in your class initialize method.
class Foo include Mutex_m def initialize # ... super() end # ... end obj = Foo.new # this obj can be handled like Mutex
Constants
No documentation available
Instance Methods
#
lib/mutex_m.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/mutex_m.rb, line 92
def mu_lock
@_mutex.lock
end
See Mutex#lock
lib/mutex_m.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/mutex_m.rb, line 82
def mu_locked?
@_mutex.locked?
end
See Mutex#locked?
lib/mutex_m.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/mutex_m.rb, line 77
def mu_synchronize(&block)
@_mutex.synchronize(&block)
end
lib/mutex_m.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/mutex_m.rb, line 87
def mu_try_lock
@_mutex.try_lock
end
See Mutex#try_lock
lib/mutex_m.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/mutex_m.rb, line 97
def mu_unlock
@_mutex.unlock
end
See Mutex#unlock
lib/mutex_m.rb
View on GitHub
# File tmp/rubies/ruby-2.7.6/lib/mutex_m.rb, line 102
def sleep(timeout = nil)
@_mutex.sleep(timeout)
end
See Mutex#sleep