HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/ecdsa/__pycache__/_rwlock.cpython-310.pyc
o

�h!�@s,ddlZdZGdd�d�ZGdd�d�ZdS)�Nz
Mateusz Kobosc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�RWLocka
    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
    cCs2t�|_t�|_t��|_t��|_t��|_dS)zz
        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��self�r
�@/usr/local/CyberCP/lib/python3.10/site-packages/ecdsa/_rwlock.py�__init__$s


zRWLock.__init__cCs:|j��|j��|j�|j�|j��|j��dS�N)r
�acquirerrr	�releaserr
r
r�reader_acquire/s



zRWLock.reader_acquirecCs|j�|j�dSr)rrr	rr
r
r�reader_release6szRWLock.reader_releasecCs|j�|j�|j��dSr)rrrr	rr
r
r�writer_acquire9szRWLock.writer_acquirecCs|j��|j�|j�dSr)r	rrrrr
r
r�writer_release=s
zRWLock.writer_releaseN)	�__name__�
__module__�__qualname__�__doc__rrrrrr
r
r
rrsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz�An 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).cCsd|_t��|_dS)Nr)�_LightSwitch__counterrr�_LightSwitch__mutexrr
r
rrFsz_LightSwitch.__init__cCs8|j��|jd7_|jdkr|��|j��dS)N��rrrr�r�lockr
r
rrJ�


z_LightSwitch.acquirecCs8|j��|jd8_|jdkr|��|j��dS)Nrrrrr
r
rrQr!z_LightSwitch.releaseN)rrrrrrrr
r
r
rrBs
r)r�
__author__rrr
r
r
r�<module>s7