File: //var/opt/nydus/ops/mysql/opentelemetry/util/__pycache__/_once.cpython-39.pyc
a
�,�h� � @ s* d dl mZ d dlmZ G dd� d�ZdS )� )�Lock)�Callablec @ s6 e Zd ZdZdd�dd�Zeg df ed�dd�ZdS ) �Oncez�Execute a function exactly once and block all callers until the function returns
Same as golang's `sync.Once <https://pkg.go.dev/sync#Once>`_
N)�returnc C s t � | _d| _d S )NF)r �_lock�_done)�self� r �Q/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/opentelemetry/util/_once.py�__init__ s z
Once.__init__)�funcr c C sV | j r
dS | j�2 | j s4|� d| _ W d � dS W d � n1 sH0 Y dS )z�Execute ``func`` if it hasn't been executed or return.
Will block until ``func`` has been called by one thread.
Returns:
Whether or not ``func`` was executed in this call
FTN)r r )r r r r r
�do_once s
.zOnce.do_once)�__name__�
__module__�__qualname__�__doc__r r �boolr
r r r r
r s r N)� threadingr �typingr r r r r r
�<module> s