Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/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.0"
[42] Fix | Delete
[43] Fix | Delete
def Mutex_m.define_aliases(cl) # :nodoc:
[44] Fix | Delete
cl.module_eval %q{
[45] Fix | Delete
alias locked? mu_locked?
[46] Fix | Delete
alias lock mu_lock
[47] Fix | Delete
alias unlock mu_unlock
[48] Fix | Delete
alias try_lock mu_try_lock
[49] Fix | Delete
alias synchronize mu_synchronize
[50] Fix | Delete
}
[51] Fix | Delete
end
[52] Fix | Delete
[53] Fix | Delete
def Mutex_m.append_features(cl) # :nodoc:
[54] Fix | Delete
super
[55] Fix | Delete
define_aliases(cl) unless cl.instance_of?(Module)
[56] Fix | Delete
end
[57] Fix | Delete
[58] Fix | Delete
def Mutex_m.extend_object(obj) # :nodoc:
[59] Fix | Delete
super
[60] Fix | Delete
obj.mu_extended
[61] Fix | Delete
end
[62] Fix | Delete
[63] Fix | Delete
def mu_extended # :nodoc:
[64] Fix | Delete
unless (defined? locked? and
[65] Fix | Delete
defined? lock and
[66] Fix | Delete
defined? unlock and
[67] Fix | Delete
defined? try_lock and
[68] Fix | Delete
defined? synchronize)
[69] Fix | Delete
Mutex_m.define_aliases(singleton_class)
[70] Fix | Delete
end
[71] Fix | Delete
mu_initialize
[72] Fix | Delete
end
[73] Fix | Delete
[74] Fix | Delete
# See Mutex#synchronize
[75] Fix | Delete
def mu_synchronize(&block)
[76] Fix | Delete
@_mutex.synchronize(&block)
[77] Fix | Delete
end
[78] Fix | Delete
[79] Fix | Delete
# See Mutex#locked?
[80] Fix | Delete
def mu_locked?
[81] Fix | Delete
@_mutex.locked?
[82] Fix | Delete
end
[83] Fix | Delete
[84] Fix | Delete
# See Mutex#try_lock
[85] Fix | Delete
def mu_try_lock
[86] Fix | Delete
@_mutex.try_lock
[87] Fix | Delete
end
[88] Fix | Delete
[89] Fix | Delete
# See Mutex#lock
[90] Fix | Delete
def mu_lock
[91] Fix | Delete
@_mutex.lock
[92] Fix | Delete
end
[93] Fix | Delete
[94] Fix | Delete
# See Mutex#unlock
[95] Fix | Delete
def mu_unlock
[96] Fix | Delete
@_mutex.unlock
[97] Fix | Delete
end
[98] Fix | Delete
[99] Fix | Delete
# See Mutex#sleep
[100] Fix | Delete
def sleep(timeout = nil)
[101] Fix | Delete
@_mutex.sleep(timeout)
[102] Fix | Delete
end
[103] Fix | Delete
[104] Fix | Delete
private
[105] Fix | Delete
[106] Fix | Delete
def mu_initialize # :nodoc:
[107] Fix | Delete
@_mutex = Thread::Mutex.new
[108] Fix | Delete
end
[109] Fix | Delete
[110] Fix | Delete
def initialize(*args) # :nodoc:
[111] Fix | Delete
mu_initialize
[112] Fix | Delete
super
[113] Fix | Delete
end
[114] Fix | Delete
end
[115] Fix | Delete
[116] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function