@@ -29,6 +29,11 @@ class MemoryCursor(object):
2929 '_size' # maximum size we should provide
3030 )
3131
32+ #{ Configuration
33+ MemoryWindowCls = MemoryWindow
34+ MappedRegionCls = MappedRegion
35+ #} END configuration
36+
3237 def __init__ (self , manager = None , regions = None ):
3338 self ._manager = manager
3439 self ._rlist = regions
@@ -129,9 +134,9 @@ def use_region(self, offset, size, flags = 0, _is_recursive=False):
129134 #END while bisecting
130135
131136 if existing_region is None :
132- left = MemoryWindow (0 , 0 )
133- mid = MemoryWindow (offset , size )
134- right = MemoryWindow (self .file_size (), 0 )
137+ left = self . MemoryWindowCls (0 , 0 )
138+ mid = self . MemoryWindowCls (offset , size )
139+ right = self . MemoryWindowCls (self .file_size (), 0 )
135140
136141 # we want to honor the max memory size, and assure we have anough
137142 # memory available
@@ -162,13 +167,13 @@ def use_region(self, offset, size, flags = 0, _is_recursive=False):
162167 # possible mapping
163168 if insert_pos == 0 :
164169 if len_regions :
165- right = MemoryWindow .from_region (a [insert_pos ])
170+ right = self . MemoryWindowCls .from_region (a [insert_pos ])
166171 #END adjust right side
167172 else :
168173 if insert_pos != len_regions :
169- right = MemoryWindow .from_region (a [insert_pos ])
174+ right = self . MemoryWindowCls .from_region (a [insert_pos ])
170175 # END adjust right window
171- left = MemoryWindow .from_region (a [insert_pos - 1 ])
176+ left = self . MemoryWindowCls .from_region (a [insert_pos - 1 ])
172177 #END adjust surrounding windows
173178
174179 mid .extend_left_to (left , window_size )
@@ -185,7 +190,7 @@ def use_region(self, offset, size, flags = 0, _is_recursive=False):
185190 if man ._handle_count >= man ._max_handle_count :
186191 raise Exception
187192 #END assert own imposed max file handles
188- self ._region = MappedRegion (a .path (), mid .ofs , mid .size , flags )
193+ self ._region = self . MappedRegionCls (a .path (), mid .ofs , mid .size , flags )
189194 except Exception :
190195 # apparently we are out of system resources or hit a limit
191196 # As many more operations are likely to fail in that condition (
@@ -302,6 +307,10 @@ class MappedMemoryManager(object):
302307 '_handle_count' , # amount of currently allocated file handles
303308 ]
304309
310+ #{ Configuration
311+ MappedRegionListCls = MappedRegionList
312+ #} END configuration
313+
305314 _MB_in_bytes = 1024 * 1024
306315
307316 def __init__ (self , window_size = 0 , max_memory_size = 0 , max_open_handles = sys .maxint ):
@@ -378,7 +387,7 @@ def make_cursor(self, path):
378387 """:return: a cursor pointing to the given path. It can be used to map new regions of the file into memory"""
379388 regions = self ._fdict .get (path )
380389 if regions is None :
381- regions = MappedRegionList (path )
390+ regions = self . MappedRegionListCls (path )
382391 self ._fdict [path ] = regions
383392 # END obtain region for path
384393 return MemoryCursor (self , regions )
0 commit comments