AlkantarClanX12

Your IP : 3.143.214.226


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-1.pyc

3

� f �@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�
BufferWrapperZwin32c@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�irZbuf�r�9/opt/alt/python36/lib64/python3.6/multiprocessing/heap.py�__init__"szArena.__init__cCst|�|jS)N)rr)rrrr�__getstate__1szArena.__getstate__cCs,|\|_|_|_tjd|j|jd�|_dS)Nr)r	r
)rrrrr)r�staterrr�__setstate__5szArena.__setstate__N)	�__name__�
__module__�__qualname__�tempfileZ_RandomNameSequencerrrrrrrrrsrc@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�r
i)r�fdr#Zmkstempr
rrZget_temp_dir�unlink�Finalizer�openr�writerr)rrr)r�fZbsZzeros�_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_arenarrZDupFd)�arrr�reduce_arenaSs
r3cCst||j��S)N)r�detach)rZdupfdrrrr1Ysr1c@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)r
r�_lastpid�	threadingZLock�_lock�_size�_lengths�_len_to_seq�_start_to_block�_stop_to_block�set�_allocated_blocks�_arenas�_pending_free_blocks)rrrrrrfs

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;�lenrE�maxr:r�PAGESIZEr�inforrA�appendr<�popr=r>)	rrr�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)	r>�KeyError�_absorbr=r<rLrGZinsortr;)	rrQrOrRrSZ
prev_blockr/Z
next_blockrNrrr�_free�s(

z
Heap._freecCs^|\}}}|j||f=|j||f=||}|j|}|j|�|sV|j|=|jj|�||fS)N)r=r>r<�remover;)rrQrOrRrSrNrPrrrrV�s


zHeap._absorbcCsFx@y|jj�}Wntk
r&PYnX|jj|�|j|�qWdS)N)rBrM�
IndexErrorr@rXrW)rrQrrr�_free_pending_blocks�szHeap._free_pending_blocksc
CsN|jjd�s|jj|�n0z"|j�|jj|�|j|�Wd|jj�XdS)NF)	r9�acquirerBrLrZr@rXrW�release)rrQrrr�free�sz	Heap.freecCs�tj�|jkr|j�|j�h|j�|jt|d�|j�}|j	|�\}}}||}||krj|j
|||f�|||f}|jj|�|SQRXdS)Nr)
r
rr7rr9rZrErI�
_alignmentrTrWr@�add)rrrOrRrSZnew_stoprQrrr�malloc�s
zHeap.mallocN)r r!r"r^rrJr�staticmethodrErTrWrVrZr]r`rrrrr5bs

r5c@s"eZdZe�Zdd�Zdd�ZdS)rcCs0tjj|�}||f|_tj|tjj|fd�dS)N)�args)r�_heapr`rrr+r])rrrQrrrr�s
zBufferWrapper.__init__cCs&|j\\}}}}t|j�|||�S)N)r�
memoryviewr)rrOrRrSrrrr�create_memoryview�szBufferWrapper.create_memoryviewN)r r!r"r5rcrrerrrrr�s)rGrr
�sysr#r8�contextrr�r�__all__�platformr�objectrr3r1�registerr5rrrrr�<module>
s$