U vi;@s8ddlmZddlmZddlmZGdddeZdS))RLock)Optional)DisposableBasecs`eZdZdZddfdd ZeedddZeddd d Ze eeZ ddd d Z Z S) 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)returncs"d|_d|_t|_tdS)zTInitializes a new instance of the SingleAssignmentDisposable class. FN) is_disposedcurrentrlocksuper__init__self __class__`/opt/alt/python38/lib/python3.8/site-packages/reactivex/disposable/singleassignmentdisposable.pyr sz#SingleAssignmentDisposable.__init__cCs|jS)N)rr rrrget_disposablesz)SingleAssignmentDisposable.get_disposable)valuerc CsF|jrtd|j|j}|s&||_W5QRX|jrB|rB|dS)Nz$Disposable has already been assigned)r Exceptionr rdispose)r rZshould_disposerrrset_disposables z)SingleAssignmentDisposable.set_disposablec CsBd}|j|js$d|_|j}d|_W5QRX|dk r>|dS)zSets the status to disposedNT)r rrr)r oldrrrr*sz"SingleAssignmentDisposable.dispose) __name__ __module__ __qualname____doc__r rrrrpropertyZ disposabler __classcell__rrrrrs   rN) threadingrtypingrZ reactivex.abcrrrrrrs