Your IP : 18.188.69.167


Current Path : /opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/multiprocessing/__pycache__/heap.cpython-34.pyo

�
e f�@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�||_xwtd�D]]}dtj�t|j�f}tjd|d|�}tj�dkriPn|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/python34/lib64/python3.4/multiprocessing/heap.py�__init__#s			zArena.__init__cCstj|�|jS)N)rZassert_spawningr)rrrr�__getstate__2s
zArena.__getstate__cCs>|\|_|_|_tjd|jd|j�|_dS)Nrr
r)rrrrr)r�staterrr�__setstate__6s!zArena.__setstate__N)	�__name__�
__module__�__qualname__�tempfileZ_RandomNameSequencerrrr rrrrrsrc@seZdZddd�ZdS)rrc
Cs�||_||_|d	kr�tjddtj�dtj��\|_}tj|�tj	|tj
|jf�t|jddd��}|jd|�WdQXnt
j
|j|j�|_dS)
Nr�prefixzpym-%d-�dir�wb�closefdFsr)r�fdr$ZmkstemprrrZget_temp_dir�unlink�Finalizer�open�writerr)rrr)r�frrrr?s			(
zArena.__init__Nr)r!r"r#rrrrrr=scCs=|jdkrtd��nt|jtj|j�ffS)NrzDArena is unpicklable because forking was enabled when it was createdr)r)�
ValueError�
rebuild_arenarrZDupFd)�arrr�reduce_arenaKsr2cCst||j��S)N)r�detach)rZdupfdrrrr0Qsr0c@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�	threadingZLock�_lock�_size�_lengths�_len_to_seq�_start_to_block�_stop_to_block�set�_allocated_blocks�_arenas�_pending_free_blocks)rrrrrr^s						z
Heap.__init__cCs|d}|||@S)Nrr)�nZ	alignment�maskrrr�_roundupks
z
Heap._roundupc	Cs	tj|j|�}|t|j�kr�|jt|j|�tj�}|jd9_t	j
d|�t|�}|jj
|�|d|fS|j|}|j|}|j�}|s�|j|=|j|=n|\}}}|j||f=|j||f=|S)N�z"allocating a new mmap of length %dr)�bisectZbisect_leftr:�lenrD�maxr9r�PAGESIZEr�inforr@�appendr;�popr<r=)	rrr�length�arena�seq�block�start�stoprrr�_mallocqs"!


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)	r=�KeyError�_absorbr<r;rKrFZinsortr:)	rrPrNrQrRZ
prev_block�_Z
next_blockrMrrr�_free�s(



z
Heap._freecCs�|\}}}|j||f=|j||f=||}|j|}|j|�|sv|j|=|jj|�n||fS)N)r<r=r;�remover:)rrPrNrQrRrMrOrrrrU�s



zHeap._absorbcCsQxJy|jj�}Wntk
r+PYnX|jj|�|j|�qWdS)N)rArL�
IndexErrorr?rXrW)rrPrrr�_free_pending_blocks�s
zHeap._free_pending_blocksc
Cse|jjd�s%|jj|�n<z+|j�|jj|�|j|�Wd|jj�XdS)NF)	r8�acquirerArKrZr?rXrW�release)rrPrrr�free�s
z	Heap.freec
Cs�tj�|jkr"|j�n|jj�|j�z�|jt|d�|j	�}|j
|�\}}}||}||kr�|j|||f�n|||f}|jj
|�|SWd|jj�XdS)Nr)rrr6rr8r[rZrDrH�
_alignmentrSrWr?�addr\)rrrNrQrRZnew_stoprPrrr�malloc�s



zHeap.mallocN)r!r"r#r^rrIr�staticmethodrDrSrWrUrZr]r`rrrrr4Zs

r4c@s1eZdZe�Zdd�Zdd�ZdS)rcCsDtjj|�}||f|_tj|tjjd|f�dS)N�args)r�_heapr`rrr+r])rrrPrrrr�szBufferWrapper.__init__cCs3|j\\}}}}t|j�|||�S)N)r�
memoryviewr)rrNrQrRrrrr�create_memoryview�szBufferWrapper.create_memoryviewN)r!r"r#r4rcrrerrrrr�s	)rFrr�sysr$r7�rrr�__all__�platformr�objectrr2r0�registerr4rrrrr�<module>
s$	�

?>