OpenQuizz
Une application de gestion des contenus pédagogiques
MapRegion Class Reference
Inheritance diagram for MapRegion:
Collaboration diagram for MapRegion:

Public Member Functions

def __init__ (self, path_or_fd, ofs, size, flags=0)
 
def __repr__ (self)
 
def buffer (self)
 
def map (self)
 
def ofs_begin (self)
 
def size (self)
 
def ofs_end (self)
 
def includes_ofs (self, ofs)
 
def client_count (self)
 
def increment_client_count (self, ofs=1)
 
def release (self)
 

Detailed Description

Defines a mapped region of memory, aligned to pagesizes

**Note:** deallocates used region automatically on destruction

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  path_or_fd,
  ofs,
  size,
  flags = 0 
)
Initialize a region, allocate the memory map
:param path_or_fd: path to the file to map, or the opened file descriptor
:param ofs: **aligned** offset into the file to be mapped
:param size: if size is larger then the file on disk, the whole file will be
    allocated the the size automatically adjusted
:param flags: additional flags to be given when opening the file.
:raise Exception: if no memory can be allocated

Member Function Documentation

◆ __repr__()

def __repr__ (   self)

◆ buffer()

def buffer (   self)
:return: a buffer containing the memory

◆ client_count()

def client_count (   self)
:return: number of clients currently using this region

◆ includes_ofs()

def includes_ofs (   self,
  ofs 
)
:return: True if the given offset can be read in our mapped region

◆ increment_client_count()

def increment_client_count (   self,
  ofs = 1 
)
Adjust 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 used

◆ map()

def map (   self)
:return: a memory map containing the memory

◆ ofs_begin()

def ofs_begin (   self)
:return: absolute byte offset to the first byte of the mapping

◆ ofs_end()

def ofs_end (   self)
:return: Absolute offset to one byte beyond the mapping into the file

◆ release()

def release (   self)
Release all resources this instance might hold. Must only be called if there usage_count() is zero

◆ size()

def size (   self)
:return: total size of the mapped region in bytes

The documentation for this class was generated from the following file: