§
    qŠtj!  ã                   óF   — d dl Z dZ G d„ d¦  «        Z G d„ d¦  «        ZdS )é    NzMateusz Kobosc                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd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
    c                 óâ   — t          ¦   «         | _        t          ¦   «         | _        t          j        ¦   «         | _        t          j        ¦   «         | _        t          j        ¦   «         | _        dS )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©Úselfs    úK/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/ecdsa/_rwlock.pyÚ__init__zRWLock.__init__$   sR   € õ
 *™^œ^ˆÔÝ*™nœnˆÔÝ%œNÑ,Ô,ˆÔÝ%œNÑ,Ô,ˆÔÝ(œ~Ñ/Ô/ˆÔÐÐó    c                 ó  — | j                              ¦   «          | j                             ¦   «          | j                             | j        ¦  «         | j                             ¦   «          | j                              ¦   «          d S ©N)r   Úacquirer   r   r   Úreleaser   s    r   Úreader_acquirezRWLock.reader_acquire/   sv   € ØÔ×$Ò$Ñ&Ô&Ð&ØÔ×!Ò!Ñ#Ô#Ð#ØÔ×"Ò" 4Ô#4Ñ5Ô5Ð5ØÔ×!Ò!Ñ#Ô#Ð#ØÔ×$Ò$Ñ&Ô&Ð&Ð&Ð&r   c                 óD   — | j                              | j        ¦  «         d S r   )r   r   r   r   s    r   Úreader_releasezRWLock.reader_release6   s"   € ØÔ×"Ò" 4Ô#4Ñ5Ô5Ð5Ð5Ð5r   c                 óv   — | j                              | j        ¦  «         | j                             ¦   «          d S r   )r   r   r   r   r   s    r   Úwriter_acquirezRWLock.writer_acquire9   s7   € ØÔ×#Ò# DÔ$5Ñ6Ô6Ð6ØÔ×!Ò!Ñ#Ô#Ð#Ð#Ð#r   c                 óv   — | j                              ¦   «          | j                             | j        ¦  «         d S r   )r   r   r   r   r   s    r   Úwriter_releasezRWLock.writer_release=   s7   € ØÔ×!Ò!Ñ#Ô#Ð#ØÔ×#Ò# DÔ$5Ñ6Ô6Ð6Ð6Ð6r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   © r   r   r   r      si   € € € € € ðð ð0	0ð 	0ð 	0ð'ð 'ð 'ð6ð 6ð 6ð$ð $ð $ð7ð 7ð 7ð 7ð 7r   r   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )r   z‘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).c                 óD   — d| _         t          j        ¦   «         | _        d S )Nr   )Ú_LightSwitch__counterr	   r
   Ú_LightSwitch__mutexr   s    r   r   z_LightSwitch.__init__F   s   € ØˆŒÝ ”~Ñ'Ô'ˆŒˆˆr   c                 óÈ   — | j                              ¦   «          | xj        dz  c_        | j        dk    r|                     ¦   «          | j                              ¦   «          d S )Né   ©r&   r   r%   r   ©r   Úlocks     r   r   z_LightSwitch.acquireJ   óZ   € ØŒ×ÒÑÔÐØˆŒ˜!ÑˆŒØŒ>˜QÒÐØ�LŠL‰NŒNˆNØŒ×ÒÑÔÐÐÐr   c                 óÈ   — | j                              ¦   «          | xj        dz  c_        | j        dk    r|                     ¦   «          | j                              ¦   «          d S )Nr(   r   r)   r*   s     r   r   z_LightSwitch.releaseQ   r,   r   N)r   r   r    r!   r   r   r   r"   r   r   r   r   B   sM   € € € € € ðNð Nð(ð (ð (ðð ð ðð ð ð ð r   r   )r	   Ú
__author__r   r   r"   r   r   ú<module>r/      su   ðð
 Ð Ð Ð ð €
ð47ð 47ð 47ð 47ð 47ñ 47ô 47ð 47ðnð ð ð ð ñ ô ð ð ð r   