
    Ϫf]                     (    d Z ddlmZ  G d d      Zy)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                   4    e Zd ZdZdZdZdZd Zd Zd Z	d Z
y)BufferingMixinz+
    Mixin which adds write buffering.
    Ng        c                 V    t        j                  | j                  | j                        S N)r   	callLaterDELAYflushselfs    5/usr/lib/python3/dist-packages/twisted/conch/mixin.pyschedulezBufferingMixin.schedule   s      TZZ88    c                 :    |j                  | j                         y r   )resetr	   )r   tokens     r   
reschedulezBufferingMixin.reschedule   s    DJJr   c                     | j                   g | _        | j                         | _         n| j                  | j                          | j                  j	                  |       y)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!   sI     !!)DI%)]]_D"OOD223		r   c                 j    d| _         | j                  j                  | j                         d| _        y)z/
        Flush the buffer immediately.
        N)r   	transportwriteSequencer   r   s    r   r
   zBufferingMixin.flush0   s)     "&$$TYY/	r   )__name__
__module____qualname____doc__r   r   r	   r   r   r   r
    r   r   r   r      s-     DE9 r   r   N)r   twisted.internetr   r   r    r   r   <module>r"      s   
 %% %r   