K i4dZddlZddlZddlmZmZddlmZgdZdZdZGdd Z Gd d Z Gd d e Z y)zlModule containing a memory memory manager which provides a sliding window on a number of memory mapped filesN)mmap ACCESS_READALLOCATIONGRANULARITY) align_to_mmap is_64_bit MapWindow MapRegion MapRegionListrcF|tztz}|r||k7r |tz }|S)a= Align the given integer number to the closest page offset, which usually is 4096 bytes. :param round_up: if True, the next higher multiple of page size is used, otherwise the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0) :return: num rounded to closest pager)numround_upress P/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/smmap/util.pyrrs. ' '+@ @CSCZ $$ Jc(tjdkDS)zO:return: True if the system is 64 bit. Otherwise it can be assumed to be 32 bitl)sysmaxsizerrrrs ;; &&rcHeZdZdZdZdZdZedZdZ dZ dZ d Z y ) r zWUtility type which is used to snap windows towards each other, and to adjust their sizeofssizec ||_||_yNr)selfoffsetrs r__init__zMapWindow.__init__-s rc8d|j|jfzS)NzMapWindow(%i, %i)rrs r__repr__zMapWindow.__repr__1s"dhh %:::rcD||j|jS)z!:return: new window from a region_br)clsregions r from_regionzMapWindow.from_region4s699fkkm,,rc4|j|jzSrrr s rofs_endzMapWindow.ofs_end9sxx$))##rct|jd}|xj|j|z z c_||_t|jd|_y)zlenstrcloseincrement_client_count) r path_or_fdrrflagsfdkwargscorrected_sizesizeofs actual_sizes rrzMapRegion.__init__cs  j# &BR[[72z13M%MPU%UVB S9F!NG bhhrl22Wr#r s rr!zMapRegion.__repr__s"dggtyy{%;;;rc|jS)z':return: a buffer containing the memoryr>r s rbufferzMapRegion.buffer xxrc|jS)z+:return: a memory map containing the memoryr[r s rmapz MapRegion.mapr]rc|jS)z>:return: absolute byte offset to the first byte of the mapping)r$r s r ofs_beginzMapRegion.ofs_begins wwrc|jS)z1:return: total size of the mapped region in bytes)r@r s rrzMapRegion.sizes zzrc4|j|jzS)zE:return: Absolute offset to one byte beyond the mapping into the filer$r@r s rr)zMapRegion.ofs_endsww##rcd|j|cxkxr|j|jzkScS)zB:return: True if the given offset can be read in our mapped regionrdrrs r includes_ofszMapRegion.includes_ofss)ww#4$** 44444rc|jS)z6:return: number of clients currently using this region)r?r s r client_countzMapRegion.client_countr]rc|xj|z c_|jdkDsJd|jz|jdk(r|jyy)zAdjust the usage count by the given positive or negative offset. If usage count equals 0, we will auto-release our resources :return: True if we released resources, False otherwise. In the latter case, we can still be usedzrPr s rrlzMapRegion.releases rN)r)r+)r7r8r9r:r;rr!r\r_rarr)rgrirQrlrrrr r SsGFI%&N< $5 rr c8eZdZdZdZfdZdZdZdZxZ S)r zFList of MapRegion instances associating a path with a list of regions. _path_or_fd _file_sizec"t||Sr)super__new__)r%path __class__s rrtzMapRegionList.__new__sws##rc ||_d|_yrro)rrRs rrzMapRegionList.__init__s%rc|jS)z3:return: path or file descriptor we are attached to)rpr s rrRzMapRegionList.path_or_fdsrc6|jt|jtr:t j |jj |_|jSt j|jj |_|jS)z :return: size of file we manager)rqrErprOrGstatrMrLr s r file_sizezMapRegionList.file_sizesn ?? "$**C0"$''$*:*:";"C"C #%((4+;+;"<"D"Dr) r7r8r9r:r;rtrrRr{ __classcell__)rvs@rr r s!PI $  rr ) r:rGrrrr__all__rrr r listr rrrrsLr "& O '+M+M\hhZDr