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__/test_rw_lock.cpython-310.pyc
o

�hm�@s�zddlZWn
eyddlZYnwddlZddlZddlZddlmZGdd�dej�Z	Gdd�dej�Z
Gdd	�d	ej�ZdS)
�N���RWLockc@�eZdZdd�Zdd�ZdS)�WritercCs<tj�|�||_||_||_||_||_d|_	d|_	dS)a�
        @param buffer_: common buffer_ shared by the readers and writers
        @type buffer_: list
        @type rw_lock: L{RWLock}
        @param init_sleep_time: sleep time before doing any action
        @type init_sleep_time: C{float}
        @param sleep_time: sleep time while in critical section
        @type sleep_time: C{float}
        @param to_write: data that will be appended to the buffer
        N)
�	threading�Thread�__init__�_Writer__buffer�_Writer__rw_lock�_Writer__init_sleep_time�_Writer__sleep_time�_Writer__to_write�
entry_time�	exit_time)�self�buffer_�rw_lock�init_sleep_time�
sleep_time�to_write�r�E/usr/local/CyberCP/lib/python3.10/site-packages/ecdsa/test_rw_lock.pyr	s
zWriter.__init__cCsRt�|j�|j��t��|_t�|j�|j�|j	�t��|_
|j��dS�N)�time�sleeprr�writer_acquirerr
r
�appendrr�writer_release�rrrr�run(�


z
Writer.runN��__name__�
__module__�__qualname__r	r rrrrrsrc@r)�ReadercCs>tj�|�||_||_||_||_d|_	d|_	d|_	dS)a\
        @param buffer_: common buffer shared by the readers and writers
        @type buffer_: list
        @type rw_lock: L{RWLock}
        @param init_sleep_time: sleep time before doing any action
        @type init_sleep_time: C{float}
        @param sleep_time: sleep time while in critical section
        @type sleep_time: C{float}
        N)
rrr	�_Reader__buffer�_Reader__rw_lock�_Reader__init_sleep_time�_Reader__sleep_time�buffer_readrr)rrrrrrrrr	3s
zReader.__init__cCsRt�|j�|j��t��|_t�|j�t�|j	�|_
t��|_|j��dSr)
rrr)r(�reader_acquirerr*�copy�deepcopyr'r+r�reader_releaserrrrr Ir!z
Reader.runNr"rrrrr&2sr&c@sDeZdZdd�Zdd�Zdd�Zdd�Zed	d
��Zedd��Z	d
S)�RWLockTestCasecCs�|��\}}}|�t||dd��|�t||ddd��|�t||dd��|�t||dd��|�|�|�g|dj�|�dg|dj�|�dg|dj�|�|dj|dj	k�|�|dj	|dj	k�|�|dj|djk�dS)	Nr皙�����?皙�����?r�333333�?��?��)
�_RWLockTestCase__init_variablesrr&r�'_RWLockTestCase__start_and_join_threads�assertEqualr+�
assertTruerr�rrr�threadsrrr� test_readers_nonexclusive_accessTs
z/RWLockTestCase.test_readers_nonexclusive_accesscCs�|��\}}}|�t||ddd��|�t||ddd��|�t||dd��|�|�|�ddg|dj�|�|dj|dj	k�|�|dj|djk�dS)Nrr2r皙�����?r5r1�
r7rrr&r8r9r+r:rrr;rrr�test_writers_exclusive_accessjs
z,RWLockTestCase.test_writers_exclusive_accesscCs,|��\}}}|�t||ddd��|�t||dd��|�t||ddd��|�t||dd��|�t||dd��|�|�|�dg|dj�|�ddg|dj�|�ddg|d	j�|�|dj|dj	k�|�|dj|dj	k�|�|dj|dj	k�|�|dj|d	j	k�dS)
Nrrr>r2r1r5r3r6�r?r;rrr�test_writer_priorityys
z#RWLockTestCase.test_writer_prioritycCs�|��\}}}|�t||ddd��|�t||dd��|�t||ddd��|�t||dd��|�t||dd��|�t||d	dd
��|�|�|�dg|dj�|�gd�|d
j�|�gd�|dj�|�|dj|dj	k�|�|dj|dj	k�|�|dj|d
j	k�|�|dj|d
j	k�|�|dj|dj	k�|�|d
j|d
j	k�|�|d
j|dj	k�dS)Nrrr>g333333�?r1r5r3r2r4r6)rr5r6rA�r?r;rrr�test_many_writers_priority�s$
z)RWLockTestCase.test_many_writers_prioritycCsg}t�}g}|||fSrr)rrr<rrr�__init_variables�s
zRWLockTestCase.__init_variablescCs(|D]}|��q|D]}|��qdSr)�start�join)r<�trrr�__start_and_join_threads�s


�z'RWLockTestCase.__start_and_join_threadsN)
r#r$r%r=r@rBrD�staticmethodr7r8rrrrr0Ss
r0)
�	unittest2�unittest�ImportErrorrrr-�_rwlockrrrr&�TestCaser0rrrr�<module>s�#!