On this page
module Mutex_m
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.
class Foo
include Mutex_m
# ...
end
obj = Foo.new
# this obj can be handled like Mutex
Public Instance Methods
# File lib/mutex_m.rb, line 84
def mu_lock
@_mutex.lock
end
See Mutex#lock
# File lib/mutex_m.rb, line 74
def mu_locked?
@_mutex.locked?
end
See Mutex#locked?
# File lib/mutex_m.rb, line 69
def mu_synchronize(&block)
@_mutex.synchronize(&block)
end
# File lib/mutex_m.rb, line 79
def mu_try_lock
@_mutex.try_lock
end
See Mutex#try_lock
# File lib/mutex_m.rb, line 89
def mu_unlock
@_mutex.unlock
end
See Mutex#unlock
# File lib/mutex_m.rb, line 94
def sleep(timeout = nil)
@_mutex.sleep(timeout)
end
See Mutex#sleep
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.