
    nVhB                     T    d dl mZ ddlmZ d dlmZ  G d d      Zdedd	fd
Z	ddZ
y	)    )proton   )get_profiling_onwrapsc                   4    e Zd ZdZdeddfdZd Zd	dZd Zy)
stateaz  
    A context manager and decorator for entering and exiting a state.

    Usage:
        context manager:
        ```python
        with proton.state("test0"):
            foo[1,](x, y)
        ```

        decorator:
        ```python
        @proton.state("test0")
        def foo(x, y):
            ...
        ```

    Args:
        name (str): The name of the state.
    namereturnNc                     || _         y Nr
   )selfr
   s     E/home/dcms/DCMS/lib/python3.12/site-packages/triton/profiler/state.py__init__zstate.__init__   s	    	    c                 \    t               s| S t        j                  | j                         | S r   )r   	libprotonenter_stater
   )r   s    r   	__enter__zstate.__enter__   s$    !Kdii(r   c                 B    t               sy t        j                          y r   )r   r   
exit_state)r   exc_type	exc_value	tracebacks       r   __exit__zstate.__exit__%   s    !r   c                 2     t               fd       }|S )Nc                      t               rt        j                  j                          | i |}t               rt        j                          |S r   )r   r   r   r
   r   )argskwargsretfuncr   s      r   wrapperzstate.__call__.<locals>.wrapper,   sA    !%%dii0''C!$$&Jr   r   )r   r"   r#   s   `` r   __call__zstate.__call__*   s     	t	 
	 r   r   N)	__name__
__module____qualname____doc__strr   r   r   r$    r   r   r	   r	      s)    *S T 
r   r	   r
   r   Nc                 .    t        j                  |        y r   )r   r   r   s    r   r   r   8   s    $r   c                  ,    t        j                          y r   )r   r   r+   r   r   r   r   <   s    r   r%   )triton._C.libprotonr   r   flagsr   	functoolsr   r	   r*   r   r   r+   r   r   <module>r1      s1    3 # / /d c  d  r   