Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/alt/ruby31/share/ruby
File: mutex_m.rb
# frozen_string_literal: false
[0] Fix | Delete
#
[1] Fix | Delete
# mutex_m.rb -
[2] Fix | Delete
# $Release Version: 3.0$
[3] Fix | Delete
# $Revision: 1.7 $
[4] Fix | Delete
# Original from mutex.rb
[5] Fix | Delete
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
[6] Fix | Delete
# modified by matz
[7] Fix | Delete
# patched by akira yamada
[8] Fix | Delete
#
[9] Fix | Delete
# --
[10] Fix | Delete
[11] Fix | Delete
# = mutex_m.rb
[12] Fix | Delete
#
[13] Fix | Delete
# When 'mutex_m' is required, any object that extends or includes Mutex_m will
[14] Fix | Delete
# be treated like a Mutex.
[15] Fix | Delete
#
[16] Fix | Delete
# Start by requiring the standard library Mutex_m:
[17] Fix | Delete
#
[18] Fix | Delete
# require "mutex_m.rb"
[19] Fix | Delete
#
[20] Fix | Delete
# From here you can extend an object with Mutex instance methods:
[21] Fix | Delete
#
[22] Fix | Delete
# obj = Object.new
[23] Fix | Delete
# obj.extend Mutex_m
[24] Fix | Delete
#
[25] Fix | Delete
# Or mixin Mutex_m into your module to your class inherit Mutex instance
[26] Fix | Delete
# methods --- remember to call super() in your class initialize method.
[27] Fix | Delete
#
[28] Fix | Delete
# class Foo
[29] Fix | Delete
# include Mutex_m
[30] Fix | Delete
# def initialize
[31] Fix | Delete
# # ...
[32] Fix | Delete
# super()
[33] Fix | Delete
# end
[34] Fix | Delete
# # ...
[35] Fix | Delete
# end
[36] Fix | Delete
# obj = Foo.new
[37] Fix | Delete
# # this obj can be handled like Mutex
[38] Fix | Delete
#
[39] Fix | Delete
module Mutex_m
[40] Fix | Delete
[41] Fix | Delete
VERSION = "0.1.1"
[42] Fix | Delete
Ractor.make_shareable(VERSION) if defined?(Ractor)
[43] Fix | Delete
[44] Fix | Delete
def Mutex_m.define_aliases(cl) # :nodoc:
[45] Fix | Delete
cl.module_eval %q{
[46] Fix | Delete
alias locked? mu_locked?
[47] Fix | Delete
alias lock mu_lock
[48] Fix | Delete
alias unlock mu_unlock
[49] Fix | Delete
alias try_lock mu_try_lock
[50] Fix | Delete
alias synchronize mu_synchronize
[51] Fix | Delete
}
[52] Fix | Delete
end
[53] Fix | Delete
[54] Fix | Delete
def Mutex_m.append_features(cl) # :nodoc:
[55] Fix | Delete
super
[56] Fix | Delete
define_aliases(cl) unless cl.instance_of?(Module)
[57] Fix | Delete
end
[58] Fix | Delete
[59] Fix | Delete
def Mutex_m.extend_object(obj) # :nodoc:
[60] Fix | Delete
super
[61] Fix | Delete
obj.mu_extended
[62] Fix | Delete
end
[63] Fix | Delete
[64] Fix | Delete
def mu_extended # :nodoc:
[65] Fix | Delete
unless (defined? locked? and
[66] Fix | Delete
defined? lock and
[67] Fix | Delete
defined? unlock and
[68] Fix | Delete
defined? try_lock and
[69] Fix | Delete
defined? synchronize)
[70] Fix | Delete
Mutex_m.define_aliases(singleton_class)
[71] Fix | Delete
end
[72] Fix | Delete
mu_initialize
[73] Fix | Delete
end
[74] Fix | Delete
[75] Fix | Delete
# See Thread::Mutex#synchronize
[76] Fix | Delete
def mu_synchronize(&block)
[77] Fix | Delete
@_mutex.synchronize(&block)
[78] Fix | Delete
end
[79] Fix | Delete
[80] Fix | Delete
# See Thread::Mutex#locked?
[81] Fix | Delete
def mu_locked?
[82] Fix | Delete
@_mutex.locked?
[83] Fix | Delete
end
[84] Fix | Delete
[85] Fix | Delete
# See Thread::Mutex#try_lock
[86] Fix | Delete
def mu_try_lock
[87] Fix | Delete
@_mutex.try_lock
[88] Fix | Delete
end
[89] Fix | Delete
[90] Fix | Delete
# See Thread::Mutex#lock
[91] Fix | Delete
def mu_lock
[92] Fix | Delete
@_mutex.lock
[93] Fix | Delete
end
[94] Fix | Delete
[95] Fix | Delete
# See Thread::Mutex#unlock
[96] Fix | Delete
def mu_unlock
[97] Fix | Delete
@_mutex.unlock
[98] Fix | Delete
end
[99] Fix | Delete
[100] Fix | Delete
# See Thread::Mutex#sleep
[101] Fix | Delete
def sleep(timeout = nil)
[102] Fix | Delete
@_mutex.sleep(timeout)
[103] Fix | Delete
end
[104] Fix | Delete
[105] Fix | Delete
private
[106] Fix | Delete
[107] Fix | Delete
def mu_initialize # :nodoc:
[108] Fix | Delete
@_mutex = Thread::Mutex.new
[109] Fix | Delete
end
[110] Fix | Delete
[111] Fix | Delete
def initialize(*args) # :nodoc:
[112] Fix | Delete
mu_initialize
[113] Fix | Delete
super
[114] Fix | Delete
end
[115] Fix | Delete
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
[116] Fix | Delete
end
[117] Fix | Delete
[118] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function