externalAllocator-class {externalVector}R Documentation

Class "externalAllocator", base class for memory allocators for external resources


Class "externalAllocator" is a virtual class with no slots. It represents memory allocators that allocate raw memory to be held in an object of class "externalptr". Instead of returning the "externalptr" object directly, the allocators deal with subclasses of "externalResource" that hold an object of class "externalptr".

Objects from the Class

A virtual Class: No objects may be created from it.

Virtual Methods

Attempt to execute these methods would result in an error unless they have been redefined for a subclass of "externalAllocator".

Signature components for implementation of the methods:

resource The class "externalResource"
alloc A subclass of "externalAllocator"
size The class "ANY"
type The class "ANY"
copy The class "logical"
value The class "ANY"

Description of the virtual methods:

allocate(resource, alloc, size, type, ...):
Allocate the external pointer in resource using the allocator alloc. If type is a basic vector object, then allocate an object of same mode with length size. Otherwise allocate size bytes of raw memory. This method should end with a call to initializeResource to initialize the resource object.
deallocate(resource, alloc):
The allocator alloc should try to dealloacte the raw memory in resource. It should not modify the resource object in any way other than modifying the object of class "externalptr" in resource to reflect the deallocation.
Return the size of the allocated memory in resource.
external.size<-(resource, copy, alloc, value):
If value is same as external.size(resource), then no action is taken. Otherwise, reallocate the memory in resource using the allocator alloc with new size value. If copy is TRUE (the default), then the new memory is initialized to the content of the old memory for the minimum of old and new sizes. Content of any uninitialized memory is undefined.
reinitializePointer(resource, alloc):
If the object resource was saved as an R image (by serialization code, by saving the R workspace, or by an explicit call to save) then the raw memory pointer in any "externalptr" object in it would be set to 0. This method tries to reinitialize the raw memory pointer. The exact result is allocator dependant.


Saikat DebRoy <saikat@stat.wisc.edu>

See Also

externalResource-class for more on how to use an allocator with objects from subclasses of "externalResource".

gcAllocator-class for an example of a subclass of "externalAllocator".

setVirtualMethod for more on virtual methods.

[Package externalVector version 1.0.14 Index]