§
    cÌc8  ã                   ó0   — d Z ddlmZ  G d„ d¦  «        ZdS )zCounted lock classé   )Úerrorsc                   óD   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dd	„Z
d
„ ZdS )ÚCountedLockzüDecorator around a lock that makes it reentrant.

    This can be used with any object that provides a basic Lock interface,
    including LockDirs and OS file locks.

    :ivar _token: While a write lock is held, this is the token
        for it.
    c                 ó0   — || _         d | _        d| _        d S ©Né    )Ú
_real_lockÚ
_lock_modeÚ_lock_count)ÚselfÚ	real_locks     ú5/usr/lib/python3/dist-packages/breezy/counted_lock.pyÚ__init__zCountedLock.__init__"   s   € Ø#ˆŒØˆŒØˆÔÐÐó    c                 óL   — d                      | j        j        | j        ¦  «        S )Nz{}({!r}))ÚformatÚ	__class__Ú__name__r	   ©r   s    r   Ú__repr__zCountedLock.__repr__'   s&   € Ø× Ò  ¤Ô!8Øœ?ñ,ô ,ð 	,r   c                 óT   — | j                              ¦   «          d | _        d| _        d S r   )r	   Ú
break_lockr
   r   r   s    r   r   zCountedLock.break_lock+   s+   € ØŒ×"Ò"Ñ$Ô$Ð$ØˆŒØˆÔÐÐr   c                 ó\   — 	 | j                              ¦   «         duS # t          $ r Y dS w xY w)záReturn physical lock status.

        Returns true if a lock is held on the transport. If no lock is held, or
        the underlying locking mechanism does not support querying lock
        status, false is returned.
        NF)r	   ÚpeekÚNotImplementedErrorr   s    r   Úget_physical_lock_statusz$CountedLock.get_physical_lock_status0   sB   € ð	Ø”?×'Ò'Ñ)Ô)°Ð5Ð5øÝ"ð 	ð 	ð 	Ø�5�5ð	øøøs   ‚ �
+ª+c                 ó   — | j         d uS ©N)r
   r   s    r   Ú	is_lockedzCountedLock.is_locked<   s   € ØŒ dÐ*Ð*r   c                 ó†   — | j         r| xj        dz  c_        dS | j                             ¦   «          d| _        d| _         dS )zÝAcquire the lock in read mode.

        If the lock is already held in either read or write mode this
        increments the count and succeeds.  If the lock is not already held,
        it is taken in read mode.
        r   ÚrN)r
   r   r	   Ú	lock_readr   s    r   r"   zCountedLock.lock_read?   sO   € ð Œ?ð 	"ØÐÔ Ñ!ÐÔÐÐàŒO×%Ò%Ñ'Ô'Ð'Ø ˆDÔØ!ˆDŒOˆOˆOr   Nc                 ó4  — | j         dk    r>| j                             |¬¦  «        | _        d| _        | xj         dz  c_         | j        S | j        dk    rt          j        | ¦  «        ‚| j                             |¦  «         | xj         dz  c_         | j        S )aA  Acquire the lock in write mode.

        If the lock was originally acquired in read mode this will fail.

        :param token: If given and the lock is already held,
            then validate that we already hold the real
            lock with this token.

        :returns: The token from the underlying lock.
        r   )ÚtokenÚwr   )r   r	   Ú
lock_writeÚ_tokenr
   r   ÚReadOnlyErrorÚvalidate_token)r   r$   s     r   r&   zCountedLock.lock_writeM   sŸ   € ð Ô˜qÒ Ð Øœ/×4Ò4¸5Ð4ÑAÔAˆDŒKØ!ˆDŒOØÐÔ Ñ!ÐÔØ”;ÐØŒ_ Ò#Ð#ÝÔ& tÑ,Ô,Ð,àŒO×*Ò*¨5Ñ1Ô1Ð1ØÐÔ Ñ!ÐÔØ”;Ðr   c                 óÞ   — | j         dk    rt          j        | ¦  «        ‚| j         dk    r2d | _        | xj         dz  c_         | j                             ¦   «          d S | xj         dz  c_         d S )Nr   r   )r   r   ÚLockNotHeldr
   r	   Úunlockr   s    r   r,   zCountedLock.unlockd   s€   € ØÔ˜qÒ Ð ÝÔ$ TÑ*Ô*Ð*ØÔ Ò"Ð"ð #ˆDŒOØÐÔ Ñ!ÐÔØŒO×"Ò"Ñ$Ô$Ð$Ð$Ð$àÐÔ Ñ!ÐÔÐÐr   r   )r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r"   r&   r,   © r   r   r   r      s›   € € € € € ðð ðð ð ð
,ð ,ð ,ðð ð ð

ð 
ð 
ð+ð +ð +ð"ð "ð "ðð ð ð ð."ð "ð "ð "ð "r   r   N)r/   Ú r   r   r0   r   r   ú<module>r2      sg   ðð" Ð ðð ð ð ð ð ð
W"ð W"ð W"ð W"ð W"ñ W"ô W"ð W"ð W"ð W"r   