1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* {ext,lib,test}/**/*.rb: removed trailing spaces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-03-06 03:56:38 +00:00
parent 9b52ae2e64
commit 287a34ae0d
856 changed files with 13989 additions and 13989 deletions

View file

@ -34,7 +34,7 @@
# Sync#lock(mode) -- mode = :EX, :SH, :UN
# Sync#unlock
# Sync#synchronize(mode) {...}
#
#
#
unless defined? Thread
@ -43,25 +43,25 @@ end
module Sync_m
RCS_ID='-$Header$-'
# lock mode
UN = :UN
SH = :SH
EX = :EX
# exceptions
class Err < StandardError
def Err.Fail(*opt)
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)
@ -72,7 +72,7 @@ module Sync_m
end
end
end
def Sync_m.define_aliases(cl)
cl.module_eval %q{
alias locked? sync_locked?
@ -84,7 +84,7 @@ module Sync_m
alias synchronize sync_synchronize
}
end
def Sync_m.append_features(cl)
super
# do nothing for Modules
@ -92,12 +92,12 @@ module Sync_m
define_aliases(cl) unless cl.instance_of?(Module)
self
end
def Sync_m.extend_object(obj)
super
obj.sync_extend
end
def sync_extend
unless (defined? locked? and
defined? shared? and
@ -115,15 +115,15 @@ module Sync_m
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
@ -132,7 +132,7 @@ module Sync_m
end
ret
end
def sync_lock(m = EX)
return unlock if m == UN
@ -153,21 +153,21 @@ module Sync_m
end
self
end
def sync_unlock(m = EX)
wakeup_threads = []
@sync_mutex.synchronize do
if sync_mode == UN
Err::UnknownLocker.Fail(Thread.current)
end
m = sync_mode if m == EX and sync_mode == SH
runnable = false
case m
when UN
Err::UnknownLocker.Fail(Thread.current)
when EX
if sync_ex_locker == Thread.current
if (self.sync_ex_count = sync_ex_count - 1) == 0
@ -182,12 +182,12 @@ module Sync_m
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
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
@ -196,7 +196,7 @@ module Sync_m
end
end
end
if runnable
if sync_upgrade_waiting.size > 0
th, count = sync_upgrade_waiting.shift
@ -218,7 +218,7 @@ module Sync_m
end
self
end
def sync_synchronize(mode = EX)
sync_lock(mode)
begin
@ -229,7 +229,7 @@ module Sync_m
end
attr_accessor :sync_mode
attr_accessor :sync_waiting
attr_accessor :sync_upgrade_waiting
attr_accessor :sync_sh_locker
@ -258,7 +258,7 @@ module Sync_m
super
sync_initialize
end
def sync_try_lock_sub(m)
case m
when SH
@ -282,7 +282,7 @@ module Sync_m
end
when EX
if sync_mode == UN or
sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
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