
    \d]                     0    d Z ddlmZ  G d d          ZdS )z
Experimental optimization

This module provides a single mixin class which allows protocols to
collapse numerous small writes into a single larger one.

@author: Jp Calderone
    )reactorc                   6    e Zd ZdZdZdZdZd Zd Zd Z	d Z
dS )BufferingMixinz+
    Mixin which adds write buffering.
    Ng        c                 @    t          j        | j        | j                  S N)r   	callLaterDELAYflushselfs    3lib/python3.11/site-packages/twisted/conch/mixin.pyschedulezBufferingMixin.schedule   s     TZ888    c                 :    |                     | j                   d S r   )resetr	   )r   tokens     r   
reschedulezBufferingMixin.reschedule   s    DJr   c                     | j         !g | _        |                                 | _         n|                     | j                    | j                            |           dS )a  
        Buffer some bytes to be written soon.

        Every call to this function delays the real write by C{self.DELAY}
        seconds.  When the delay expires, all collected bytes are written
        to the underlying transport using L{ITransport.writeSequence}.
        N)_delayedWriteCalldatar   r   append)r   r   s     r   writezBufferingMixin.write!   sX     !)DI%)]]__D""OOD2333	r   c                 `    d| _         | j                            | j                   d| _        dS )z/
        Flush the buffer immediately.
        N)r   	transportwriteSequencer   r   s    r   r
   zBufferingMixin.flush0   s/     "&$$TY///			r   )__name__
__module____qualname____doc__r   r   r	   r   r   r   r
    r   r   r   r      sl          DE9 9 9           r   r   N)r   twisted.internetr   r   r    r   r   <module>r"      sU   
  % $ $ $ $ $% % % % % % % % % %r   