allocators {externalVector}R Documentation

Generics associated with external resources and their allocators

Description

These are generics used with objects of class "externalResource" and "externalAllocator".

Usage

allocator(resource)
getPointer(resource)
initializeResource(resource, ptr, size, type, ...)
allocatedSize(resource)
allocatedType(resource)
allocate(resource, alloc, size, type, ...)
deallocate(resource, alloc)
external.size(resource, alloc)
external.size(resource, copy, alloc) <- value
reinitializePointer(resource, alloc)

Arguments

resource An object which is an "externalResource".
alloc An object which is an "externalAllocator".
ptr An external pointer.
size The size - if given for a non-vector type, the numebr of bytes. Otherwise, the length of the vector.
type Object represnting the type stored in the resource.
copy Logical, if 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. Under any circumstance, the inherent type of the allocated memory remains the same as its initial value.
value Integer, new size.
... Further arguments passed to or from other functions.

Value

allocator returns the allocator to be used by default with resource.
getPointer returns the "externalptr" associated with resource.
initializeResource intializes resource with ptr of type "externalptr" and returns resource.
allocatedSize returns the size of memory to be allocated for resource. If allocatedType(resource) is an R basic vector type, then the size is the length of the vector. Otherwise the size is the total number of bytes.
allocatedType returns an object representing the type to be stored in the resource
allocate allocates the external pointer in resource using the allocator alloc for resource. If type is a basic vector object, then it allocates an object of same mode with length size and otherwise allocates size bytes of raw memory. The resource object is initialized by a call to initializeResource.
deallocate asks the allocator alloc to deallocate the memory in resource. The result is allocator dependant.
external.size returns the argument size used in the last call to allocate for resource.
The replacement form can be used to change the size of the allocated memory. If value is same as external.size(resource), then no action is taken. Otherwise, this reallocates the memory in resource using the allocator alloc (or allocator(resource) if alloc is missing) with new size value and the same type as earlier.
reinitializePointer tries to reinitialize the memory pointer in resource after resource was saved and restored as an R image (by serialization code, by saving the R workspace, or by an explicit call to save).

See Also

externalAllocator-class, externalResource-class


[Package externalVector version 1.0.14 Index]