�`^c@s
ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z m
Z
ddlmZdgZ
ejdkr�ddlmZdefd��YZndefd ��YZd
efd��YZdefd��YZdS(
i�N(tFinalizetinfo(tassert_spawningt
BufferWrappertwin32(RtArenacBs/eZej�Zd�Zd�Zd�ZRS(cCs�||_dtj�tjj�f|_tjd|jd|j�|_t j
�dksjtd��|j|jf|_dS(Ns pym-%d-%di�ttagnameistagname already in use(
tsizetostgetpidRt_countertnexttnametmmaptbufferRtGetLastErrortAssertionErrort_state(tselfR((s*/sys/lib/python2.7/multiprocessing/heap.pyt__init__=s
"!cCst|�|jS(N(RR(R((s*/sys/lib/python2.7/multiprocessing/heap.pyt__getstate__Ds
cCsY|\|_|_|_tjd|jd|j�|_tj�tjksUt�dS(Ni�R( RRRR
RRRtERROR_ALREADY_EXISTSR(Rtstate((s*/sys/lib/python2.7/multiprocessing/heap.pyt__setstate__Hs!(t__name__t
__module__t itertoolstcountR
RRR(((s*/sys/lib/python2.7/multiprocessing/heap.pyR9s cBseZd�ZRS(cCs+tjd|�|_||_d|_dS(Ni�(R
RRtNoneR(RR((s*/sys/lib/python2.7/multiprocessing/heap.pyRQs (RRR(((s*/sys/lib/python2.7/multiprocessing/heap.pyROstHeapcBsbeZdZejd�Zed��Zd�Zd�Z d�Z
d�Zd�Zd�Z
RS( icCsmtj�|_tj�|_||_g|_i|_i|_ i|_
t�|_g|_
g|_dS(N(RR t_lastpidt threadingtLockt_lockt_sizet_lengthst_len_to_seqt_start_to_blockt_stop_to_blocktsett_allocated_blockst_arenast_pending_free_blocks(RR((s*/sys/lib/python2.7/multiprocessing/heap.pyR^s cCs|d}|||@S(Ni((tnt alignmenttmask((s*/sys/lib/python2.7/multiprocessing/heap.pyt_roundupks
c Cstj|j|�}|t|j�kr�|jt|j|�tj�}|jd9_t d|�t
|�}|jj|�|d|fS|j|}|j
|}|j�}|s�|j
|=|j|=n|\}}}|j||f=|j||f=|S(Nis"allocating a new mmap of length %di(tbisecttbisect_leftR#tlenR.tmaxR"R
tPAGESIZERRR)tappendR$tpopR%R&( RRtitlengthtarenatseqtblocktstarttstop((s*/sys/lib/python2.7/multiprocessing/heap.pyt_mallocqs"!
c Cs!|\}}}y|j||f}Wntk
r9nX|j|�\}}y|j||f}Wntk
rynX|j|�\}}|||f}||}y|j|j|�Wn4tk
r�|g|j|<tj|j|�nX||j||f<||j||f<dS(N( R&tKeyErrort_absorbR%R$R4R/tinsortR#( RR:R8R;R<t
prev_blockt_t
next_blockR7((s*/sys/lib/python2.7/multiprocessing/heap.pyt_free�s(
cCs�|\}}}|j||f=|j||f=||}|j|}|j|�|sv|j|=|jj|�n||fS(N(R%R&R$tremoveR#(RR:R8R;R<R7R9((s*/sys/lib/python2.7/multiprocessing/heap.pyR?�s
cCsVxOtrQy|jj�}Wntk
r0PnX|jj|�|j|�qWdS(N(tTrueR*R5t
IndexErrorR(RERD(RR:((s*/sys/lib/python2.7/multiprocessing/heap.pyt_free_pending_blocks�s
cCs�tj�|jkst�|jjt�s@|jj|�n<z+|j �|j
j|�|j|�Wd|jj
�XdS(N(RR RRR!tacquiretFalseR*R4RHR(RERDtrelease(RR:((s*/sys/lib/python2.7/multiprocessing/heap.pytfree�s
cCs�d|kotjkns%t�tj�|jkrG|j�n|jj�|j �z�|j
t|d�|j�}|j
|�\}}}||}||kr�|j|||f�n|||f}|jj|�|SWd|jj�XdS(Nii(tsystmaxintRRR RRR!RIRHR.R2t
_alignmentR=RDR(taddRK(RRR8R;R<tnew_stopR:((s*/sys/lib/python2.7/multiprocessing/heap.pytmalloc�s%
(RRROR
R3RtstaticmethodR.R=RDR?RHRLRR(((s*/sys/lib/python2.7/multiprocessing/heap.pyRZs
cBs,eZe�Zd�Zd�Zd�ZRS(cCsfd|kotjkns%t�tjj|�}||f|_t|tjjd|f�dS(Nitargs( RMRNRRt_heapRRRRRL(RRR:((s*/sys/lib/python2.7/multiprocessing/heap.pyR�s%cCsJ|j\\}}}}tj|j�\}}||ksBt�||S(N(Rt_multiprocessingtaddress_of_bufferRR(RR8R;R<RtaddressR7((s*/sys/lib/python2.7/multiprocessing/heap.pytget_address�scCs|jdS(Ni(R(R((s*/sys/lib/python2.7/multiprocessing/heap.pytget_size�s(RRRRURRYRZ(((s*/sys/lib/python2.7/multiprocessing/heap.pyR�s (R/R
ttempfileRRMRRRVtmultiprocessing.utilRRtmultiprocessing.forkingRt__all__tplatformRtobjectRRR(((s*/sys/lib/python2.7/multiprocessing/heap.pyt<module>#s
|