o
    Ã¿i!  ã                   @   s,   d Z ddlZddlmZ G dd„ deƒZdS )z(System clock implementation for Pipecat.é    N)Ú	BaseClockc                   @   s.   e Zd ZdZdd„ Zdefdd„Zdd„ Zd	S )
ÚSystemClocka   A monotonic clock implementation using system time.

    Provides high-precision timing using the system's monotonic clock,
    which is not affected by system clock adjustments and is suitable
    for measuring elapsed time in real-time applications.
    c                 C   s
   d| _ dS )z¹Initialize the system clock.

        The clock starts in an uninitialized state and must be started
        explicitly using the start() method before time measurement begins.
        r   N)Ú_time©Úself© r   úO/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/clocks/system_clock.pyÚ__init__   s   
zSystemClock.__init__Úreturnc                 C   s   | j dkrt ¡ | j  S dS )zÏGet the elapsed time since the clock was started.

        Returns:
            The elapsed time in nanoseconds since start() was called.
            Returns 0 if the clock has not been started yet.
        r   )r   ÚtimeÚmonotonic_nsr   r   r   r   Úget_time   s   zSystemClock.get_timec                 C   s   t  ¡ | _dS )z¤Start the clock and begin time measurement.

        Records the current monotonic time as the reference point
        for all subsequent get_time() calls.
        N)r   r   r   r   r   r   r   Ústart'   s   zSystemClock.startN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   Úintr   r   r   r   r   r   r      s
    	r   )r   r   Úpipecat.clocks.base_clockr   r   r   r   r   r   Ú<module>   s   