a
    õ£Bek  ã                   @   sX   d Z ddlmZmZ ddlmZmZmZ ddlm	Z	 ddlm
Z G dd„ dƒZdgZd	S )
zzmq Context classé    )ÚEINVALÚ
IO_THREADS)ÚInterruptedSystemCallÚZMQErrorÚ	_check_rcé   )Úffi)Úlibc                   @   sV   e Zd ZdZdZdZdZddd„Zedd„ ƒZ	ed	d
„ ƒZ
dd„ Zdd„ Zdd„ ZdS )ÚContextNTFr   c                 C   sp   |rt  d|¡| _d| _n d| _|dks0ttƒ‚t ¡ | _| jt jkrRtt 	¡ ƒ‚|sft 
| jt|¡ d| _d S )Nzvoid *TFr   )r   ÚcastÚ_zmq_ctxÚ_shadowr   r   ÚCZzmq_ctx_newZNULLZ	zmq_errnoÚzmq_ctx_setr   Ú_closed)ÚselfZ
io_threadsZshadow© r   ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/zmq/backend/cffi/context.pyÚ__init__   s    
zContext.__init__c                 C   s   t t d| j¡ƒS )z,The address of the underlying libzmq contextZsize_t)Úintr   r   r   ©r   r   r   r   Ú
underlying#   s    zContext.underlyingc                 C   s   | j S )N)r   r   r   r   r   Úclosed(   s    zContext.closedc                 C   s   t  | j||¡}t|ƒ dS )z6set a context option

        see zmq_ctx_set
        N)r   r   r   r   )r   ÚoptionÚvalueÚrcr   r   r   Úset,   s    zContext.setc                 C   s   t  | j|¡}t|dd� |S )z4get context option

        see zmq_ctx_get
        F)Zerror_without_errno)r   Zzmq_ctx_getr   r   )r   r   r   r   r   r   Úget4   s    zContext.getc                 C   sF   | j r
d S t | j¡}zt|ƒ W n ty4   Y n0 d | _d| _d S )NT)r   r   Zzmq_ctx_destroyr   r   r   r   )r   r   r   r   r   Úterm=   s    zContext.term)r   N)Ú__name__Ú
__module__Ú__qualname__r   Z
_iothreadsr   r   r   Úpropertyr   r   r   r   r   r   r   r   r   r
      s   


	r
   N)Ú__doc__Zzmq.constantsr   r   Z	zmq.errorr   r   r   Z_cffir   r	   r   r
   Ú__all__r   r   r   r   Ú<module>   s   @