+
    üÐjZ  ã                  ót  a € 0 t $ R t^ RIHt ^ RIHtHt ^ RIHtH	t	H
t
HtHtHt ]'       d   ^ RIt^ RIHt ^RIHt ^RIHt  ! R R	]4      t]P,                  t]! R
4      t]! R4      t ! R R]],          4      tR]R&   ]t]! ]4       ! R R4      4       t ! R R]4      t]! ]4       ! R R4      4       t R# )zE
Implementation of an L{IWorker} based on native threads and queues.
)Úannotations)ÚEnumÚauto)ÚTYPE_CHECKINGÚCallableÚIteratorÚLiteralÚProtocolÚTypeVarN)Úimplementer)ÚQuit)ÚIExclusiveWorkerc                  ó$   € ] tR t^t]! 4       tRtR# )ÚStop© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   ÚThreadÚ__static_attributes__r   ó    Ú@/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.pyr   r      s	   † Ù‹V„Fr   r   ÚTÚUc                  ó.   € ] tR t^ tR R ltR R ltRtR# )ÚSimpleQueuec               ó    € V ^8„  d   QhRRRR/# )é   Úitemr   ÚreturnÚNoner   )Úformats   "r   Ú__annotate__ÚSimpleQueue.__annotate__!   s   € ÷ ñ ˜ð ˜dñ r   c                	ó   € R # ©Nr   )Úselfr   s   &&r   ÚputÚSimpleQueue.put!   ó   € Ùr   c               ó   € V ^8„  d   QhRR/# )r   r    r   r   )r"   s   "r   r#   r$   $   s   € ÷ ñ �Qñ r   c                	ó   € R # r&   r   ©r'   s   &r   ÚgetÚSimpleQueue.get$   r*   r   r   N)r   r   r   r   r(   r.   r   r   r   r   r   r       ó   † õ÷ñ r   r   z/Callable[[Callable[[], T | U], U], Iterator[T]]Ú	smartiterc                  ó>   € ] tR t^-tRtR R ltR R ltR R ltRtR	# )
ÚThreadWorkerzê
An L{IExclusiveWorker} implemented based on a single thread and a queue.

This worker ensures exclusivity (i.e. it is an L{IExclusiveWorker} and not
an L{IWorker}) by performing all of the work passed to C{do} on the I{same}
thread.
c               ó    € V ^8„  d   QhRRRR/# )r   ÚstartThreadz(Callable[[Callable[[], object]], object]Úqueuez8SimpleQueue[Callable[[], object] | Literal[Stop.Thread]]r   )r"   s   "r   r#   ÚThreadWorker.__annotate__7   s   € ÷ ñ à=ðð Hñr   c                óV   a€ SV n         \        4       V n        R V3R llpV! V4       R# )a   
Create a L{ThreadWorker} with a function to start a thread and a queue
to use to communicate with that thread.

@param startThread: a callable that takes a callable to run in another
    thread.

@param queue: A L{Queue} to use to give tasks to the thread created by
    C{startThread}.
c               ó   € V ^8„  d   QhRR/# ©r   r    r!   r   )r"   s   "r   r#   Ú+ThreadWorker.__init__.<locals>.__annotate__I   s   € ÷ 	ñ 	�dñ 	r   c                 óX   <€ \        SP                  \        4       F
  p V ! 4        K  	  R # r&   )r1   r.   Ú
StopThread)Útaskr6   s    €r   ÚworkÚ#ThreadWorker.__init__.<locals>.workI   s   ø€ Ü! %§)¡)¬ZÖ8�Ù–ó 9r   N)Ú_qr   Ú_hasQuit)r'   r5   r6   r?   s   &&f r   Ú__init__ÚThreadWorker.__init__7   s)   ø€ ð ˆŒÜ›ˆŒ÷	ð 	ñ 	�DÖr   c               ó    € V ^8„  d   QhRRRR/# )r   r>   úCallable[[], None]r    r!   r   )r"   s   "r   r#   r7   O   s   € ÷ ñ Ð)ð ¨dñ r   c                óp   € V P                   P                  4        V P                  P                  V4       R# )zu
Perform the given task on the thread owned by this L{ThreadWorker}.

@param task: the function to call on a thread.
N)rB   ÚcheckrA   r(   )r'   r>   s   &&r   ÚdoÚThreadWorker.doO   s$   € ð 	�‰×ÑÔØ�‰�‰�DÖr   c               ó   € V ^8„  d   QhRR/# r:   r   )r"   s   "r   r#   r7   X   s   € ÷  ñ  �dñ  r   c                óx   € V P                   P                  4        V P                  P                  \        4       R# )zD
Reject all future work and stop the thread started by C{__init__}.
N)rB   ÚsetrA   r(   r=   r-   s   &r   ÚquitÚThreadWorker.quitX   s$   € ð 	�‰×ÑÔØ�‰�‰”JÖr   )rB   rA   N©	r   r   r   r   Ú__doc__rC   rI   rN   r   r   r   r   r3   r3   -   s   † ñõõ0÷ ñ  r   r3   c                  ó.   € ] tR t^btR R ltR R ltRtR# )Ú
SimpleLockc               ó   € V ^8„  d   QhRR/# )r   r    Úboolr   )r"   s   "r   r#   ÚSimpleLock.__annotate__c   ó   € ÷ ñ ˜ñ r   c                	ó   € R # r&   r   r-   s   &r   ÚacquireÚSimpleLock.acquirec   r*   r   c               ó   € V ^8„  d   QhRR/# r:   r   )r"   s   "r   r#   rV   f   rW   r   c                	ó   € R # r&   r   r-   s   &r   ÚreleaseÚSimpleLock.releasef   r*   r   r   N)r   r   r   r   rY   r]   r   r   r   r   rS   rS   b   r0   r   rS   c                  ó>   € ] tR t^jtRtR R ltR R ltR R ltRtR	# )
Ú
LockWorkerz=
An L{IWorker} implemented based on a mutual-exclusion lock.
c               ó    € V ^8„  d   QhRRRR/# )r   ÚlockrS   Úlocalzthreading.localr   )r"   s   "r   r#   ÚLockWorker.__annotate__p   s   € ÷ ñ ˜Zð °ñ r   c                ó<   € \        4       V n        Wn        W n        R# )z¯
@param lock: A mutual-exclusion lock, with C{acquire} and C{release}
    methods.
@type lock: L{threading.Lock}

@param local: Local storage.
@type local: L{threading.local}
N)r   Ú_quitÚ_lockÚ_local)r'   rb   rc   s   &&&r   rC   ÚLockWorker.__init__p   s   € ô “VˆŒ
Ø(,Œ
ØŽr   c               ó    € V ^8„  d   QhRRRR/# )r   r?   rF   r    r!   r   )r"   s   "r   r#   rd   }   s   € ÷ !ñ !Ð)ð !¨dñ !r   c                óÄ  € V P                   pV P                  pV P                  P                  4        \	        VRR4      pVfp   Vf   Q R4       h. ;qCn        VP                  V4       VP                  4         V'       d   VP                  ^ 4      ! 4        K    VP                  4        RVn        R# VP                  V4       R#   TP                  4        RTn        i ; i)zÇ
Do the given work on this thread, with the mutex acquired.  If this is
called re-entrantly, return and wait for the outer invocation to do the
work.

@param work: the work to do with the lock held.
ÚworkingNzLockWorker used after quit())
rg   rh   rf   rH   Úgetattrrl   ÚappendrY   Úpopr]   )r'   r?   rb   rc   rl   s   &&   r   rI   ÚLockWorker.do}   s·   € ð �z‰zˆØ—‘ˆØ�
‰
×ÑÔÜ˜% ¨DÓ1ˆØŠ?ØÒ#ÐCÐ%CÓCÐ#Ø&(Ð(ˆG”mØ�N‰N˜4Ô Ø�L‰LŒNð%ßØ—K‘K ”NÖ$ð ð —‘”Ø $�–à�N‰N˜4Ö øð —‘”Ø $�•ús   Á9C ÂC ÃCc               ó   € V ^8„  d   QhRR/# r:   r   )r"   s   "r   r#   rd   —   s   € ÷ ñ �dñ r   c                óH   € V P                   P                  4        RV n        R# )z
Quit this L{LockWorker}.
N)rf   rM   rg   r-   s   &r   rN   ÚLockWorker.quit—   s   € ð 	�
‰
�‰ÔØˆŽ
r   )rh   rg   rf   NrP   r   r   r   r`   r`   j   s   † ñõõ!÷4ñ r   r`   )!Ú__conditional_annotations__rQ   Ú
__future__r   Úenumr   r   Útypingr   r   r   r   r	   r
   Ú	threadingÚzope.interfacer   Ú_conveniencer   Ú	_ithreadsr   r   r   r=   r   r   r   Ú__annotations__Úiterr1   r3   rS   r`   )rt   s   @r   Ú<module>r~      s¹   øðô
õ #ç ß P× PçÛå &å Ý 'ôˆ4ô ð �[‰[€
áˆCƒL€ÙˆCƒL€ô�(˜1•+ô ð ;Ó :Ø€	ñ ÐÓ÷1 ð 1 ó ð1 ôh�ô ñ ÐÓ÷1ð 1ó ò1r   