Your IP : 18.191.205.149


Current Path : /opt/alt/python36/lib64/python3.6/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/multiprocessing/__pycache__/heap.cpython-36.opt-2.pyc

3

��2a �@s�ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
dgZejdkrvddl
Z
Gdd�de�Zn,Gd	d�de�Zd
d�Zdd
�Zejee�Gdd�de�ZGdd�de�ZdS)�N�)�	reduction�assert_spawning)�util�
BufferWrapper�win32c@s,eZdZej�Zdd�Zdd�Zdd�ZdS)�ArenacCsz||_xTtd�D]@}dtj�t|j�f}tjd||d�}tj�dkrHP|j	�qWt
d��||_||_|j|jf|_
dS)N�dz	pym-%d-%sr)�tagnamerzCannot find name for new mmap���)�size�range�os�getpid�next�_rand�mmap�_winapiZGetLastError�close�FileExistsError�name�buffer�_state)�selfr�ir�buf�r�)/opt/alt/python36/lib64/python3.6/heap.py�__init__"szArena.__init__cCst|�|jS)N)rr)rrrr�__getstate__1szArena.__getstate__cCs,|\|_|_|_tjd|j|jd�|_dS)Nr)r
r)rrrrr)r�staterrr�__setstate__5szArena.__setstate__N)	�__name__�
__module__�__qualname__�tempfileZ_RandomNameSequencerrrr!rrrrrsrc@seZdZddd�ZdS)rrcCs�||_||_|d	kr�tjdtj�tj�d�\|_}tj|�tj	|tj
|jf�t|jddd��N}d
}||kr�d|}xt||�D]}|j
|�q�W~|j
d||�WdQRXtj|j|j�|_dS)Nrzpym-%d-)�prefix�dir�wbF)�closefdi�ri)r�fdr%ZmkstemprrrZget_temp_dir�unlink�Finalizer�openr
�writerr)rrr+r�f�bsZzeros�_rrrr@s"

zArena.__init__Nr)r)r"r#r$rrrrrr>scCs(|jdkrtd��t|jtj|j�ffS)NrzDArena is unpicklable because forking was enabled when it was createdr)r+�
ValueError�
rebuild_arenarrZDupFd)�arrr�reduce_arenaSs
r6cCst||j��S)N)r�detach)rZdupfdrrrr4Ysr4c@sZeZdZdZejfdd�Zedd��Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�ZdS)�Heap�cCsJtj�|_tj�|_||_g|_i|_i|_	i|_
t�|_g|_
g|_dS)N)rr�_lastpid�	threadingZLock�_lock�_size�_lengths�_len_to_seq�_start_to_block�_stop_to_block�set�_allocated_blocks�_arenas�_pending_free_blocks)rrrrrrfs

z
Heap.__init__cCs|d}|||@S)Nrr)�nZ	alignment�maskrrr�_roundupssz
Heap._roundupc	Cs�tj|j|�}|t|j�krj|jt|j|�tj�}|jd9_t	j
d|�t|�}|jj
|�|d|fS|j|}|j|}|j�}|s�|j|=|j|=|\}}}|j||f=|j||f=|S)N�z"allocating a new mmap of length %dr)�bisectZbisect_leftr>�lenrH�maxr=r�PAGESIZEr�inforrD�appendr?�popr@rA)	rrr�length�arena�seq�block�start�stoprrr�_mallocys"



zHeap._mallocc	Cs�|\}}}y|j||f}Wntk
r0YnX|j|�\}}y|j||f}Wntk
rfYnX|j|�\}}|||f}||}y|j|j|�Wn.tk
r�|g|j|<tj|j|�YnX||j||f<||j||f<dS)N)	rA�KeyError�_absorbr@r?rOrJZinsortr>)	rrTrRrUrVZ
prev_blockr2Z
next_blockrQrrr�_free�s(

z
Heap._freecCs^|\}}}|j||f=|j||f=||}|j|}|j|�|sV|j|=|jj|�||fS)N)r@rAr?�remover>)rrTrRrUrVrQrSrrrrY�s


zHeap._absorbcCsFx@y|jj�}Wntk
r&PYnX|jj|�|j|�qWdS)N)rErP�
IndexErrorrCr[rZ)rrTrrr�_free_pending_blocks�szHeap._free_pending_blocksc
CsN|jjd�s|jj|�n0z"|j�|jj|�|j|�Wd|jj�XdS)NF)	r<�acquirerErOr]rCr[rZ�release)rrTrrr�free�sz	Heap.freecCs�tj�|jkr|j�|j�h|j�|jt|d�|j�}|j	|�\}}}||}||krj|j
|||f�|||f}|jj|�|SQRXdS)Nr)
rrr:rr<r]rHrL�
_alignmentrWrZrC�add)rrrRrUrVZnew_stoprTrrr�malloc�s
zHeap.mallocN)r"r#r$rarrMr�staticmethodrHrWrZrYr]r`rcrrrrr8bs

r8c@s"eZdZe�Zdd�Zdd�ZdS)rcCs0tjj|�}||f|_tj|tjj|fd�dS)N)�args)r�_heaprcrrr-r`)rrrTrrrr�s
zBufferWrapper.__init__cCs&|j\\}}}}t|j�|||�S)N)r�
memoryviewr)rrRrUrVrrrr�create_memoryview�szBufferWrapper.create_memoryviewN)r"r#r$r8rfrrhrrrrr�s)rJrr�sysr%r;�contextrr�r�__all__�platformr�objectrr6r4�registerr8rrrrr�<module>
s$
 

?>