Your IP : 3.149.25.26


Current Path : /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/heap.cpython-35.opt-2.pyc



���]� �@s#ddlZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	dgZ
ejdkr�ddlZGdd	�d	e
�Zn>Gd
d	�d	e
�Zdd�Zd
d�Zejee�Gdd�de
�ZGdd�de
�ZdS)�N�)�context)�	reduction)�util�
BufferWrapper�win32c@s@eZdZej�Zdd�Zdd�Zdd�ZdS)�ArenacCs�||_xttd�D]Z}dtj�t|j�f}tjd|d|�}tj�dkrfP|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/python35/lib64/python3.5/heap.py�__init__#s			zArena.__init__cCstj|�|jS)N)r�assert_spawningr)rrrr�__getstate__2s
zArena.__getstate__cCs>|\|_|_|_tjd|jd|j�|_dS)Nrr
r)rrrrr)r�staterrr�__setstate__6szArena.__setstate__N)	�__name__�
__module__�__qualname__�tempfile�_RandomNameSequencerrr r"rrrrrsrc@seZdZddd�ZdS)rrcCs||_||_|d
kr�tjddtj�dtj��\|_}tj|�tj	|tj
|jf�t|jddd��c}d}||kr�d	|}x%t||�D]}|j
|�q�W~|j
d	||�WdQRXtj|j|j�|_dS)Nr�prefixzpym-%d-�dir�wb�closefdFisri)r�fdr&�mkstemprrr�get_temp_dir�unlink�Finalizer�openr
�writerr)rrr,r�f�bsZzeros�_rrrrAs"			(

zArena.__init__Nr)r#r$r%rrrrrr?scCs:|jdkrtd��t|jtj|j�ffS)NrzDArena is unpicklable because forking was enabled when it was createdr)r,�
ValueError�
rebuild_arenarr�DupFd)�arrr�reduce_arenaTsr:cCst||j��S)N)r�detach)rZdupfdrrrr7Zsr7c@s�eZdZdZejdd�Zedd��Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�ZdS)�Heap�cCsmtj�|_tj�|_||_g|_i|_i|_	i|_
t�|_g|_
g|_dS)N)rr�_lastpid�	threading�Lock�_lock�_size�_lengths�_len_to_seq�_start_to_block�_stop_to_block�set�_allocated_blocks�_arenas�_pending_free_blocks)rrrrrrgs						z
Heap.__init__cCs|d}|||@S)Nrr)�nZ	alignment�maskrrr�_roundupts
z
Heap._roundupc	Cstj|j|�}|t|j�kr�|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_leftrC�lenrM�maxrBr�PAGESIZEr�inforrI�appendrD�poprErF)	rrr�length�arena�seq�block�start�stoprrr�_malloczs"!


zHeap._mallocc	Cs$|\}}}y|j||f}Wntk
r:YnX|j|�\}}y|j||f}Wntk
r{YnX|j|�\}}|||f}||}y|j|j|�Wn5tk
r�|g|j|<tj|j|�YnX||j||f<||j||f<dS)N)	rF�KeyError�_absorbrErDrTrOZinsortrC)	rrYrWrZr[Z
prev_blockr5Z
next_blockrVrrr�_free�s(



z
Heap._freecCs}|\}}}|j||f=|j||f=||}|j|}|j|�|ss|j|=|jj|�||fS)N)rErFrD�removerC)rrYrWrZr[rVrXrrrr^�s



zHeap._absorbcCsQxJy|jj�}Wntk
r+PYnX|jj|�|j|�qWdS)N)rJrU�
IndexErrorrHr`r_)rrYrrr�_free_pending_blocks�s
zHeap._free_pending_blocksc
Cse|jjd�s%|jj|�n<z+|j�|jj|�|j|�Wd|jj�XdS)NF)	rA�acquirerJrTrbrHr`r_�release)rrYrrr�free�s
z	Heap.freecCs�tj�|jkr|j�|j��|j�|jt|d�|j�}|j	|�\}}}||}||kr�|j
|||f�|||f}|jj|�|SWdQRXdS)Nr)
rrr>rrArbrMrQ�
_alignmentr\r_rH�add)rrrWrZr[Znew_stoprYrrr�malloc�s



zHeap.mallocN)r#r$r%rfrrRr�staticmethodrMr\r_r^rbrerhrrrrr<cs

r<c@s1eZdZe�Zdd�Zdd�ZdS)rcCsDtjj|�}||f|_tj|tjjd|f�dS)N�args)r�_heaprhrrr0re)rrrYrrrr�szBufferWrapper.__init__cCs3|j\\}}}}t|j�|||�S)N)r�
memoryviewr)rrWrZr[rrrr�create_memoryview�szBufferWrapper.create_memoryviewN)r#r$r%r<rkrrmrrrrr�s	)rOrr�sysr&r?�rrr�__all__�platformr�objectrr:r7�registerr<rrrrr�<module>
s$	 �

?>