
    qi!                     2    d Z ddlZddlmZ  G d de      Zy)z(System clock implementation for Pipecat.    N)	BaseClockc                   (    e Zd ZdZd ZdefdZd Zy)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                     d| _         y)zInitialize 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selfs    M/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/clocks/system_clock.py__init__zSystemClock.__init__   s     
    returnc                 f    | j                   dkD  r!t        j                         | j                   z
  S dS )zGet 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   s    r
   get_timezSystemClock.get_time   s+     48::>t  "TZZ/HqHr   c                 6    t        j                         | _        y)zStart 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   s    r
   startzSystemClock.start'   s     &&(
r   N)__name__
__module____qualname____doc__r   intr   r    r   r
   r   r      s    I# I)r   r   )r   r   pipecat.clocks.base_clockr   r   r   r   r
   <module>r      s    /  /)) )r   