MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/self/root/usr/lib/python2.4/Demo/metaclasses/Synch.pyc
mò
‚=5Dc@sÄdZdkZdfd„ƒYZd„ZdklZlZlZdefd„ƒYZdefd	„ƒYZ	d
efd„ƒYZ
e
dfhƒZd
„Ze
djoeƒeƒndS(s`Synchronization metaclass.

This metaclass  makes it possible to declare synchronized methods.

NtLockcBs,tZdZd„Zdd„Zd„ZRS(s Reentrant lock.

    This is a mutex-like object which can be acquired by the same
    thread more than once.  It keeps a reference count of the number
    of times it has been acquired by the same thread.  Each acquire()
    call must be matched by a release() call and only the last
    release() call actually releases the lock for acquisition by
    another thread.

    The implementation uses two locks internally:

    __mutex is a short term lock used to protect the instance variables
    __wait is the lock for which other threads wait

    A thread intending to acquire both locks should acquire __wait
    first.

   The implementation uses two other instance variables, protected by
   locking __mutex:

    __tid is the thread ID of the thread that currently has the lock
    __count is the number of times the current thread has acquired it

    When the lock is released, __tid is None and __count is zero.

    cCs4tiƒ|_tiƒ|_d|_d|_dS(s0Constructor.  Initialize all instance variables.iN(tthreadt
allocate_locktselft_Lock__mutext_Lock__waittNonet
_Lock__tidt_Lock__count(R((t,/usr/lib/python2.4/Demo/metaclasses/Synch.pyt__init__*s
	icCsê|iiƒz2|itiƒjo|id|_dSnWd|iiƒX|ii|ƒ}|o|odSnz[|iiƒ|idjpt‚|idjpt‚tiƒ|_d|_dSWd|iiƒXdS(s}Acquire the lock.

        If the optional flag argument is false, returns immediately
        when it cannot acquire the __wait lock without blocking (it
        may still block for a little while in order to acquire the
        __mutex lock).

        The return value is only relevant when the flag argument is
        false; it is 1 if the lock is acquired, 0 if not.

        iNi(
RRtacquireRRt	get_identRtreleaseRtflagtlockedRtAssertionError(RRR((R	R1s(

	cCs”|iiƒzr|itiƒjpt‚|idjpt‚|id|_|idjod|_|i	i
ƒnWd|ii
ƒXdS(sìRelease the lock.

        If this thread doesn't currently have the lock, an assertion
        error is raised.

        Only allow another thread to acquire the lock when the count
        reaches zero after decrementing it.

        iiN(RRRRRRRRRRR
(R((R	R
Qs	
	(t__name__t
__module__t__doc__R
RR
(((R	R
s	 cCsög}|d„}||d„}tƒ}|iƒ||ƒ|iƒ|iƒti||fƒti|||fƒti||fƒti||fƒ|iƒdk	}x0t
|ƒdjot
|ƒGH|idƒq·Wt
|ƒGHdS(NcCs3|iƒdtiƒG|iƒ|idƒdS(Nsf2 running in thread %d
i(tlockRRRR
tdonetappend(RR((R	tf2ks

cCsE|iƒdtiƒGz||ƒWd|iƒX|idƒdS(Nsf1 running in thread %d
i(RRRRRR
RR(RRR((R	tf1qs
i	f0.001(RRRRRRR
Rtstart_new_threadttimetlentsleep(RRRRR((R	t	_testLockgs&		




	(s	MetaClasss
MetaHelpersMetaMethodWrappertLockingMethodWrappercBstZd„ZRS(NcOs’|id djo5|iddjo!t|i|if||ƒSn|iiiƒz!t|i|if||ƒSWd|iii	ƒXdS(Nit_(
RRtapplytfunctinsttargstkwt__lock__RR
(RR#R$((R	t__call__•s(!!(RRR&(((R	R”st
LockingHelpercBstZeZd„ZRS(NcCs ti||ƒtƒ|_dS(N(t
MetaHelpert__helperinit__RtformalclassRR%(RR*((R	R) s(RRRt__methodwrapper__R)(((R	R'žstLockingMetaClasscBstZeZRS(N(RRR't
__helper__(((R	R,¤stLockingcCsÒdtfd„ƒY}dd„}dd„}tiƒ}|iƒtiƒ}|iƒ|dƒ}d}ti||||fƒti||||fƒ|iƒdGH|iƒdGHd	Gt|i	ƒGHdS(
NtBuffercBs#tZd„Zd„Zd„ZRS(NcCsD|djpt‚||_dg|i|_d|_|_dS(Ni(tinitialsizeRRtsizeRtbuffertfirsttlast(RR0((R	R
¬s	cCsP|id|i|ijo/||i|i<|id|i|_dSndG|iGHd|i|i|ifGH|i|ijo|i|i|i!}n|i|i|i|i }dG|GH|dg|id|_d|_|id|_|id|_dG|iGHdG|iGHd|i|i|ifGH|i|ƒdS(	Nisbuffer =s first = %d, last = %d, size = %dstemp =iisBuffer size doubled tosnew buffer =(	RR4R1R3titemR2ttempRtput(RR5R6((R	R7±s$		cCsH|i|ijo
t‚n|i|i}|id|i|_|S(Ni(RR3R4tEOFErrorR2R5R1(RR5((R	tgetËs

(RRR
R7R9(((R	R/«s		iècCs_dk}d}x2||jo$dG|GH|i|ƒ|d}qWdG|GdGH|iƒdS(NiR7isProducer: done producingtitems(RtitnR2R7twaitR
(R2R=R<R;R((R	tproducerÓs	
	

cCs¿dk}d}d}xŒ||jo~yM|iƒ}||jotd||f‚ndG|GH|d}d}Wqtj
o|i	|ƒ|d}qXqWdG|GdGH|iƒdS(	Nif0.001sget() returned %s, expected %stgotiisConsumer: done consumingR:(RR;ttoutR<R2R9txRR8RR=R
(R2R=R<R;R@RRA((R	tconsumerÝs"	

	



is
Producer donesAll donesbuffer size ==(
R.R/R>RBRRtpwaitRtcwaitR2R<RR(R>R/RCR<R2RDRB((R	t_test©s (




t__main__(RRRRtMetat	MetaClassR(tMetaMethodWrapperRR'R,R.RER(R'RRRER.R,R(RRIRRH((R	t?s	Z	+
	U