U
vi; @ s8 d dl mZ d dlmZ d dlmZ G dd deZdS ) )RLock)Optional)DisposableBasec s` e Zd ZdZdd fddZee dddZeddd d
Ze eeZ
ddddZ ZS )
SingleAssignmentDisposablea& Single assignment disposable.
Represents a disposable resource which only allows a single
assignment of its underlying disposable resource. If an underlying
disposable resource has already been set, future attempts to set the
underlying disposable resource will throw an Error.N)returnc s" d| _ d| _t | _t dS )zTInitializes a new instance of the SingleAssignmentDisposable
class.
FN)is_disposedcurrentr locksuper__init__self __class__ `/opt/alt/python38/lib/python3.8/site-packages/reactivex/disposable/singleassignmentdisposable.pyr s z#SingleAssignmentDisposable.__init__c C s | j S )N)r r r r r get_disposable s z)SingleAssignmentDisposable.get_disposable)valuer c C sF | j rtd| j | j}|s&|| _ W 5 Q R X | jrB|rB| d S )Nz$Disposable has already been assigned)r Exceptionr r dispose)r
r Zshould_disposer r r set_disposable s
z)SingleAssignmentDisposable.set_disposablec C sB d}| j | js$d| _| j}d| _W 5 Q R X |dk r>| dS )zSets the status to disposedNT)r r r r )r
oldr r r r * s z"SingleAssignmentDisposable.dispose)
__name__
__module____qualname____doc__r r r r r propertyZ
disposabler
__classcell__r r r r r s
r N) threadingr typingr Z
reactivex.abcr r r r r r