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

Public Member Functions

def __init__ (self, window_size=0, max_memory_size=0, max_open_handles=sys.maxsize)
 
def make_cursor (self, path_or_fd)
 
def collect (self)
 
def num_file_handles (self)
 
def num_open_files (self)
 
def window_size (self)
 
def mapped_memory_size (self)
 
def max_file_handles (self)
 
def max_mapped_memory_size (self)
 
def force_map_handle_removal_win (self, base_path)
 

Static Public Attributes

 MapRegionListCls
 
 MapWindowCls
 
 MapRegionCls
 
 WindowCursorCls
 

Detailed Description

Provides a manager which will produce single size cursors that are allowed
to always map the whole file.

Clients must be written to specifically know that they are accessing their data
through a StaticWindowMapManager, as they otherwise have to deal with their window size.

These clients would have to use a SlidingWindowMapBuffer to hide this fact.

This type will always use a maximum window size, and optimize certain methods to
accommodate this fact

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  window_size = 0,
  max_memory_size = 0,
  max_open_handles = sys.maxsize 
)
initialize the manager with the given parameters.
:param window_size: if -1, a default window size will be chosen depending on
    the operating system's architecture. It will internally be quantified to a multiple of the page size
    If 0, the window may have any size, which basically results in mapping the whole file at one
:param max_memory_size: maximum amount of memory we may map at once before releasing mapped regions.
    If 0, a viable default will be set depending on the system's architecture.
    It is a soft limit that is tried to be kept, but nothing bad happens if we have to over-allocate
:param max_open_handles: if not maxint, limit the amount of open file handles to the given number.
    Otherwise the amount is only limited by the system itself. If a system or soft limit is hit,
    the manager will free as many handles as possible

Reimplemented in SlidingWindowMapManager.

Member Function Documentation

◆ collect()

def collect (   self)
Collect all available free-to-collect mapped regions
:return: Amount of freed handles

◆ force_map_handle_removal_win()

def force_map_handle_removal_win (   self,
  base_path 
)
ONLY AVAILABLE ON WINDOWS
On windows removing files is not allowed if anybody still has it opened.
If this process is ourselves, and if the whole process uses this memory
manager (as far as the parent framework is concerned) we can enforce
closing all memory maps whose path matches the given base path to
allow the respective operation after all.
The respective system must NOT access the closed memory regions anymore !
This really may only be used if you know that the items which keep
the cursors alive will not be using it anymore. They need to be recreated !
:return: Amount of closed handles

**Note:** does nothing on non-windows platforms

◆ make_cursor()

def make_cursor (   self,
  path_or_fd 
)
:return: a cursor pointing to the given path or file descriptor.
    It can be used to map new regions of the file into memory

**Note:** if a file descriptor is given, it is assumed to be open and valid,
but may be closed afterwards. To refer to the same file, you may reuse
your existing file descriptor, but keep in mind that new windows can only
be mapped as long as it stays valid. This is why the using actual file paths
are preferred unless you plan to keep the file descriptor open.

**Note:** file descriptors are problematic as they are not necessarily unique, as two
different files opened and closed in succession might have the same file descriptor id.

**Note:** Using file descriptors directly is faster once new windows are mapped as it
prevents the file to be opened again just for the purpose of mapping it.

◆ mapped_memory_size()

def mapped_memory_size (   self)
:return: amount of bytes currently mapped in total

◆ max_file_handles()

def max_file_handles (   self)
:return: maximium amount of handles we may have opened

◆ max_mapped_memory_size()

def max_mapped_memory_size (   self)
:return: maximum amount of memory we may allocate

◆ num_file_handles()

def num_file_handles (   self)
:return: amount of file handles in use. Each mapped region uses one file handle

◆ num_open_files()

def num_open_files (   self)
Amount of opened files in the system

◆ window_size()

def window_size (   self)
:return: size of each window when allocating new regions

Field Documentation

◆ MapRegionCls

MapRegionCls
static

◆ MapRegionListCls

MapRegionListCls
static

◆ MapWindowCls

MapWindowCls
static

◆ WindowCursorCls

WindowCursorCls
static

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