X7ROOT File Manager
Current Path:
/opt/alt/ruby18/lib64/ruby/1.8
opt
/
alt
/
ruby18
/
lib64
/
ruby
/
1.8
/
??
..
??
English.rb
(5.6 KB)
??
Env.rb
(274 B)
??
abbrev.rb
(2.5 KB)
??
base64.rb
(3.37 KB)
??
benchmark.rb
(17.73 KB)
??
bigdecimal
??
cgi
??
cgi-lib.rb
(6.89 KB)
??
cgi.rb
(73.74 KB)
??
complex.rb
(12.84 KB)
??
csv.rb
(24.46 KB)
??
date
??
date.rb
(53.02 KB)
??
date2.rb
(128 B)
??
debug.rb
(20.61 KB)
??
delegate.rb
(8.81 KB)
??
digest
??
digest.rb
(1.12 KB)
??
dl
??
drb
??
drb.rb
(19 B)
??
e2mmap.rb
(4.04 KB)
??
erb.rb
(21.38 KB)
??
eregex.rb
(487 B)
??
expect.rb
(633 B)
??
fileutils.rb
(42.23 KB)
??
finalize.rb
(5.38 KB)
??
find.rb
(1.84 KB)
??
forwardable.rb
(6.16 KB)
??
ftools.rb
(6.17 KB)
??
generator.rb
(8.1 KB)
??
getoptlong.rb
(14.88 KB)
??
getopts.rb
(2.25 KB)
??
gserver.rb
(6.43 KB)
??
importenv.rb
(590 B)
??
io
??
ipaddr.rb
(21.96 KB)
??
irb
??
irb.rb
(7.43 KB)
??
jcode.rb
(4.3 KB)
??
kconv.rb
(8.12 KB)
??
logger.rb
(17.59 KB)
??
mailread.rb
(1.28 KB)
??
mathn.rb
(5.42 KB)
??
matrix.rb
(27.21 KB)
??
md5.rb
(411 B)
??
mkmf.rb
(50.65 KB)
??
monitor.rb
(7.93 KB)
??
mutex_m.rb
(2.07 KB)
??
net
??
observer.rb
(5.15 KB)
??
open-uri.rb
(20.49 KB)
??
open3.rb
(2.1 KB)
??
openssl
??
openssl.rb
(575 B)
??
optparse
??
optparse.rb
(47.12 KB)
??
ostruct.rb
(3.35 KB)
??
parsearg.rb
(1.55 KB)
??
parsedate.rb
(1.33 KB)
??
pathname.rb
(29.39 KB)
??
ping.rb
(1.48 KB)
??
pp.rb
(15.97 KB)
??
prettyprint.rb
(18.33 KB)
??
profile.rb
(90 B)
??
profiler.rb
(1.59 KB)
??
pstore.rb
(11.15 KB)
??
racc
??
rational.rb
(12.05 KB)
??
rdoc
??
readbytes.rb
(835 B)
??
resolv-replace.rb
(1.55 KB)
??
resolv.rb
(56.83 KB)
??
rexml
??
rinda
??
rss
??
rss.rb
(504 B)
??
rubyunit.rb
(180 B)
??
runit
??
scanf.rb
(20.63 KB)
??
securerandom.rb
(4.27 KB)
??
set.rb
(27.08 KB)
??
sha1.rb
(418 B)
??
shell
??
shell.rb
(4.66 KB)
??
shellwords.rb
(3.99 KB)
??
singleton.rb
(8.08 KB)
??
soap
??
sync.rb
(6.09 KB)
??
tempfile.rb
(4.86 KB)
??
test
??
thread.rb
(104 B)
??
thwait.rb
(4.32 KB)
??
time.rb
(31.58 KB)
??
timeout.rb
(3 KB)
??
tmpdir.rb
(3.69 KB)
??
tracer.rb
(2.73 KB)
??
tsort.rb
(7.99 KB)
??
un.rb
(4.54 KB)
??
uri
??
uri.rb
(710 B)
??
weakref.rb
(2.68 KB)
??
webrick
??
webrick.rb
(811 B)
??
wsdl
??
x86_64-linux
??
xmlrpc
??
xsd
??
yaml
??
yaml.rb
(12.36 KB)
Editing: sync.rb
# # sync.rb - 2 phase lock with counter # $Release Version: 1.0$ # $Revision: 22457 $ # $Date: 2009-02-20 01:41:12 +0900 (Fri, 20 Feb 2009) $ # by Keiju ISHITSUKA(keiju@ishitsuka.com) # # -- # Sync_m, Synchronizer_m # Usage: # obj.extend(Sync_m) # or # class Foo # include Sync_m # : # end # # Sync_m#sync_mode # Sync_m#sync_locked?, locked? # Sync_m#sync_shared?, shared? # Sync_m#sync_exclusive?, sync_exclusive? # Sync_m#sync_try_lock, try_lock # Sync_m#sync_lock, lock # Sync_m#sync_unlock, unlock # # Sync, Synchronicer: # include Sync_m # Usage: # sync = Sync.new # # Sync#mode # Sync#locked? # Sync#shared? # Sync#exclusive? # Sync#try_lock(mode) -- mode = :EX, :SH, :UN # Sync#lock(mode) -- mode = :EX, :SH, :UN # Sync#unlock # Sync#synchronize(mode) {...} # # unless defined? Thread fail "Thread not available for this ruby interpreter" end module Sync_m RCS_ID='-$Header$-' # lock mode UN = :UN SH = :SH EX = :EX # exceptions class Err < StandardError def Err.Fail(*opt) Thread.critical = false fail self, sprintf(self::Message, *opt) end class UnknownLocker < Err Message = "Thread(%s) not locked." def UnknownLocker.Fail(th) super(th.inspect) end end class LockModeFailer < Err Message = "Unknown lock mode(%s)" def LockModeFailer.Fail(mode) if mode.id2name mode = id2name end super(mode) end end end def Sync_m.define_aliases(cl) cl.module_eval %q{ alias locked? sync_locked? alias shared? sync_shared? alias exclusive? sync_exclusive? alias lock sync_lock alias unlock sync_unlock alias try_lock sync_try_lock alias synchronize sync_synchronize } end def Sync_m.append_features(cl) super unless cl.instance_of?(Module) # do nothing for Modules # make aliases and include the proper module. define_aliases(cl) end end def Sync_m.extend_object(obj) super obj.sync_extended end def sync_extended unless (defined? locked? and defined? shared? and defined? exclusive? and defined? lock and defined? unlock and defined? try_lock and defined? synchronize) Sync_m.define_aliases(class<<self;self;end) end sync_initialize end # accessing def sync_locked? sync_mode != UN end def sync_shared? sync_mode == SH end def sync_exclusive? sync_mode == EX end # locking methods. def sync_try_lock(mode = EX) return unlock if mode == UN Thread.critical = true ret = sync_try_lock_sub(mode) Thread.critical = false ret end def sync_lock(m = EX) return unlock if m == UN until (Thread.critical = true; sync_try_lock_sub(m)) if sync_sh_locker[Thread.current] sync_upgrade_waiting.push [Thread.current, sync_sh_locker[Thread.current]] sync_sh_locker.delete(Thread.current) else sync_waiting.push Thread.current end Thread.stop end Thread.critical = false self end def sync_unlock(m = EX) Thread.critical = true if sync_mode == UN Thread.critical = false Err::UnknownLocker.Fail(Thread.current) end m = sync_mode if m == EX and sync_mode == SH runnable = false case m when UN Thread.critical = false Err::UnknownLocker.Fail(Thread.current) when EX if sync_ex_locker == Thread.current if (self.sync_ex_count = sync_ex_count - 1) == 0 self.sync_ex_locker = nil if sync_sh_locker.include?(Thread.current) self.sync_mode = SH else self.sync_mode = UN end runnable = true end else Err::UnknownLocker.Fail(Thread.current) end when SH if (count = sync_sh_locker[Thread.current]).nil? Err::UnknownLocker.Fail(Thread.current) else if (sync_sh_locker[Thread.current] = count - 1) == 0 sync_sh_locker.delete(Thread.current) if sync_sh_locker.empty? and sync_ex_count == 0 self.sync_mode = UN runnable = true end end end end if runnable if sync_upgrade_waiting.size > 0 for k, v in sync_upgrade_waiting sync_sh_locker[k] = v end wait = sync_upgrade_waiting self.sync_upgrade_waiting = [] Thread.critical = false for w, v in wait w.run end else wait = sync_waiting self.sync_waiting = [] Thread.critical = false for w in wait w.run end end end Thread.critical = false self end def sync_synchronize(mode = EX) begin sync_lock(mode) yield ensure sync_unlock end end attr :sync_mode, true attr :sync_waiting, true attr :sync_upgrade_waiting, true attr :sync_sh_locker, true attr :sync_ex_locker, true attr :sync_ex_count, true private def sync_initialize @sync_mode = UN @sync_waiting = [] @sync_upgrade_waiting = [] @sync_sh_locker = Hash.new @sync_ex_locker = nil @sync_ex_count = 0 end def initialize(*args) sync_initialize super end def sync_try_lock_sub(m) case m when SH case sync_mode when UN self.sync_mode = m sync_sh_locker[Thread.current] = 1 ret = true when SH count = 0 unless count = sync_sh_locker[Thread.current] sync_sh_locker[Thread.current] = count + 1 ret = true when EX # in EX mode, lock will upgrade to EX lock if sync_ex_locker == Thread.current self.sync_ex_count = sync_ex_count + 1 ret = true else ret = false end end when EX if sync_mode == UN or sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current) self.sync_mode = m self.sync_ex_locker = Thread.current self.sync_ex_count = 1 ret = true elsif sync_mode == EX && sync_ex_locker == Thread.current self.sync_ex_count = sync_ex_count + 1 ret = true else ret = false end else Thread.critical = false Err::LockModeFailer.Fail mode end return ret end end Synchronizer_m = Sync_m class Sync #Sync_m.extend_class self include Sync_m def initialize super end end Synchronizer = Sync
Upload File
Create Folder