U
    bh                     @  sl   d Z ddlmZ ddlmZ dZzddlmZ W n  e	k
rP   ddlm
Z Y nX e ZG dd deZdS )	zObject Utilities.    )annotations)RLock)cached_property)threaded_cached_propertyc                      sP   e Zd ZdZd fdd	Zd fdd	Zdd Zd	d
 Zdd Zdd Z	  Z
S )r   z"Implementation of Cached property.Nc                   sB   t  | || _|| _t| ds,| jj| _t| ds>t | _	d S )Nattrnamelock)
super__init___cached_property__set_cached_property__delhasattrfunc__name__r   r   r   )selffgetfsetfdel	__class__ 7/tmp/pip-unpacked-wheel-earovzxb/kombu/utils/objects.pyr	      s    


zcached_property.__init__c              
     s,   | j  t ||W  5 Q R  S Q R X d S N)r   r   __get__)r   instanceownerr   r   r   r   $   s    zcached_property.__get__c              	   C  sH   |d kr| S | j , | jd k	r*| ||}|j}||| j< W 5 Q R X d S r   )r   r
   __dict__r   )r   r   valuecacher   r   r   __set__*   s    
zcached_property.__set__c              	   C  sL   |d kr| S | j 0 |j| jt}| jr>|tk	r>| || W 5 Q R X d S r   )r   r   popr   
_NOT_FOUNDr   )r   r   r   r   r   r   
__delete__5   s    zcached_property.__delete__c                 C  s   |  | j|| jS r   )r   r   r   )r   r   r   r   r   setter?   s    zcached_property.setterc                 C  s   |  | j| j|S r   )r   r   r
   )r   r   r   r   r   deleterB   s    zcached_property.deleter)NNN)N)r   
__module____qualname____doc__r	   r   r   r!   r"   r#   __classcell__r   r   r   r   r      s   
r   N)r&   
__future__r   	threadingr   __all__	functoolsr   Z_cached_propertyImportErrorr   objectr    r   r   r   r   <module>   s   