ruby / 3.1 / mutex_m.html

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 — 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

VERSION

Public Instance Methods

mu_lock() Show source
# File lib/mutex_m.rb, line 93
def mu_lock
  @_mutex.lock
end

See Thread::Mutex#lock

mu_locked?() Show source
# File lib/mutex_m.rb, line 83
def mu_locked?
  @_mutex.locked?
end

See Thread::Mutex#locked?

mu_synchronize(&block) Show source
# File lib/mutex_m.rb, line 78
def mu_synchronize(&block)
  @_mutex.synchronize(&block)
end

See Thread::Mutex#synchronize

mu_try_lock() Show source
# File lib/mutex_m.rb, line 88
def mu_try_lock
  @_mutex.try_lock
end

See Thread::Mutex#try_lock

mu_unlock() Show source
# File lib/mutex_m.rb, line 98
def mu_unlock
  @_mutex.unlock
end

See Thread::Mutex#unlock

sleep(timeout = nil) Show source
# File lib/mutex_m.rb, line 103
def sleep(timeout = nil)
  @_mutex.sleep(timeout)
end

See Thread::Mutex#sleep

Ruby Core © 1993–2022 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.