§
    Ètºf0  ã                   óÆ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ  e	¦   «         Z
 ee¦  «         G d„ d¦  «        ¦   «         Z ee¦  «         G d	„ d
¦  «        ¦   «         ZdS )zE
Implementation of an L{IWorker} based on native threads and queues.
é    )ÚCallable)Úimplementeré   )ÚQuit)ÚIExclusiveWorkerc                   ó>   — e Zd ZdZd„ Zdeg df         ddfd„Zd„ ZdS )Ú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                 ó\   ‡— ‰| _         t          ¦   «         | _        ˆfd„} ||¦  «         dS )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.
        @type startThread: callable taking a 0-argument callable and returning
            nothing.

        @param queue: A L{Queue} to use to give tasks to the thread created by
            C{startThread}.
        @type queue: L{Queue}
        c                  óV   •— t          ‰j        t          ¦  «        D ]}  | ¦   «          Œd S )N)ÚiterÚgetÚ_stop)ÚtaskÚqueues    €ú]/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/_threads/_threadworker.pyÚworkz#ThreadWorker.__init__.<locals>.work/   s5   ø€ Ý˜UœY­Ñ.Ô.ð ð �Ø�‘”��ðð ó    N)Ú_qr   Ú_hasQuit)ÚselfÚstartThreadr   r   s     ` r   Ú__init__zThreadWorker.__init__   sH   ø€ ð ˆŒÝ™œˆŒð	ð 	ð 	ð 	ð 	ð 	ˆ�DÑÔÐÐÐr   r   NÚreturnc                 ól   — | j                              ¦   «          | j                             |¦  «         dS )z�
        Perform the given task on the thread owned by this L{ThreadWorker}.

        @param task: the function to call on a thread.
        N)r   Úcheckr   Úput)r   r   s     r   ÚdozThreadWorker.do5   s2   € ð 	Œ×ÒÑÔÐØŒ�Š�DÑÔÐÐÐr   c                 óv   — | j                              ¦   «          | j                             t          ¦  «         dS )zT
        Reject all future work and stop the thread started by C{__init__}.
        N)r   Úsetr   r   r   ©r   s    r   ÚquitzThreadWorker.quit>   s2   € ð 	Œ×ÒÑÔÐØŒ�Š•EÑÔÐÐÐr   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r!   © r   r   r	   r	      sg   € € € € € ðð ðð ð ð.�x  D Ô)ð ¨dð ð ð ð ðð ð ð ð r   r	   c                   ó>   — e Zd ZdZd„ Zdeg df         ddfd„Zd„ ZdS )Ú
LockWorkerzE
    An L{IWorker} implemented based on a mutual-exclusion lock.
    c                 óH   — t          ¦   «         | _        || _        || _        dS )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   ÚlockÚlocals      r   r   zLockWorker.__init__N   s!   € õ ‘V”VˆŒ
ØˆŒ
ØˆŒˆˆr   r   Nr   c                 óÆ  — | j         }| j        }| j                             ¦   «          t	          |dd¦  «        }|€‘g x}|_        |                     |¦  «         |                     ¦   «          	 |r |                     d¦  «        ¦   «          |°| 	                    ¦   «          d|_        dS # | 	                    ¦   «          d|_        w xY w|                     |¦  «         dS )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.
        ÚworkingNr   )
r,   r-   r+   r   Úgetattrr1   ÚappendÚacquireÚpopÚrelease)r   r   r.   r/   r1   s        r   r   zLockWorker.do[   së   € ð ŒzˆØ”ˆØŒ
×ÒÑÔÐÝ˜% ¨DÑ1Ô1ˆØˆ?Ø&(Ð(ˆG�e”mØ�NŠN˜4Ñ Ô Ð Ø�LŠL‰NŒNˆNð%Øð %Ø"�G—K’K ‘N”NÑ$Ô$Ð$ð ð %ð —’‘”�Ø $�”��øð —’‘”�Ø $�”Ð$Ð$Ð$Ð$à�NŠN˜4Ñ Ô Ð Ð Ð s   Á.!B, Â,C	c                 óF   — | j                              ¦   «          d| _        dS )z*
        Quit this L{LockWorker}.
        N)r+   r   r,   r    s    r   r!   zLockWorker.quitt   s!   € ð 	Œ
�ŠÑÔÐØˆŒ
ˆ
ˆ
r   r"   r'   r   r   r)   r)   H   sg   € € € € € ðð ðð ð ð!�x  D Ô)ð !¨dð !ð !ð !ð !ð2ð ð ð ð r   r)   N)r&   Útypingr   Úzope.interfacer   Ú_conveniencer   Ú	_ithreadsr   Úobjectr   r	   r)   r'   r   r   ú<module>r=      sï   ðð
ð ð
 Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &à Ð Ð Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'àˆ‰Œ€ð €ÐÑÔð0ð 0ð 0ð 0ð 0ñ 0ô 0ñ Ôð0ðf €ÐÑÔð0ð 0ð 0ð 0ð 0ñ 0ô 0ñ Ôð0ð 0ð 0r   