
    [Ah!                     8    S SK r Sr " S S5      r " S S5      rg)    NzMateusz Kobosc                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
RWLock   a  
Read-Write locking primitive

Synchronization object used in a solution of so-called second
readers-writers problem. In this problem, many readers can simultaneously
access a share, and a writer has an exclusive access to this share.
Additionally, the following constraints should be met:
1) no reader should be kept waiting if the share is currently opened for
   reading unless a writer is also waiting for the share,
2) no writer should be kept waiting for the share longer than absolutely
   necessary.

The implementation is based on [1, secs. 4.2.2, 4.2.6, 4.2.7]
with a modification -- adding an additional lock (C{self.__readers_queue})
-- in accordance with [2].

Sources:
[1] A.B. Downey: "The little book of semaphores", Version 2.1.5, 2008
[2] P.J. Courtois, F. Heymans, D.L. Parnas:
    "Concurrent Control with 'Readers' and 'Writers'",
    Communications of the ACM, 1971 (via [3])
[3] http://en.wikipedia.org/wiki/Readers-writers_problem
c                     [        5       U l        [        5       U l        [        R                  " 5       U l        [        R                  " 5       U l        [        R                  " 5       U l        g)zb
A lock giving an even higher priority to the writer in certain
cases (see [2] for a discussion).
N)_LightSwitch_RWLock__read_switch_RWLock__write_switch	threadingLock_RWLock__no_readers_RWLock__no_writers_RWLock__readers_queueselfs    TC:\Users\julio\Documents\inmobiliaria_backend\env\Lib\site-packages\ecdsa/_rwlock.py__init__RWLock.__init__$   sE    
 *^*n%NN,%NN,(~~/    c                    U R                   R                  5         U R                  R                  5         U R                  R                  U R                  5        U R                  R                  5         U R                   R                  5         g N)r   acquirer   r   r   releaser   s    r   reader_acquireRWLock.reader_acquire/   sd    $$&!!#""4#4#45!!#$$&r   c                 N    U R                   R                  U R                  5        g r   )r   r   r   r   s    r   reader_releaseRWLock.reader_release6   s    ""4#4#45r   c                     U R                   R                  U R                  5        U R                  R                  5         g r   )r	   r   r   r   r   s    r   writer_acquireRWLock.writer_acquire9   s.    ##D$5$56!!#r   c                     U R                   R                  5         U R                  R                  U R                  5        g r   )r   r   r	   r   r   s    r   writer_releaseRWLock.writer_release=   s.    !!###D$5$56r   )__no_readers__no_writers__read_switch__readers_queue__write_switchN)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r"   __static_attributes__ r   r   r   r      s     0	0'6$7r   r   c                   *    \ rS rSrSrS rS rS rSrg)r   B   zAn auxiliary "light switch"-like object. The first thread turns on the
"switch", the last one turns it off (see [1, sec. 4.2.2] for details).c                 F    SU l         [        R                  " 5       U l        g )Nr   )_LightSwitch__counterr
   r   _LightSwitch__mutexr   s    r   r   _LightSwitch.__init__F   s     ~~'r   c                     U R                   R                  5         U =R                  S-  sl        U R                  S:X  a  UR                  5         U R                   R                  5         g )N   r4   r   r3   r   r   locks     r   r   _LightSwitch.acquireJ   E    !>>QLLNr   c                     U R                   R                  5         U =R                  S-  sl        U R                  S:X  a  UR                  5         U R                   R                  5         g )Nr7   r   r8   r9   s     r   r   _LightSwitch.releaseQ   r<   r   )	__counter__mutexN)	r)   r*   r+   r,   r-   r   r   r   r.   r/   r   r   r   r   B   s    N(r   r   )r
   
__author__r   r   r/   r   r   <module>rB      s&   
  
47 47n r   