Jump to content

1 Screenshot

About This File

Author:

bsvingen - Bjornar Svingen

--see readme file for contact information

Description:

A set of VIs that creates and controls pointer-data pairs. The basic idea is to simulate random access memory and malloc()/free() by using one single LV2 style global. The data type must specified in "..\Pointer\Data Typedef\Data Typedef__P.vi", or it can be replaced with an LVOOP class for LV 8.2. The only restriction to the number of references is the physical memory on the computer. The global stores data in an Array and uses a separate Bool Array to control access and free/protect the data.

The "address" to the data is returned directly with no type conversion (int32). Basicly the LV2 global takes data as input, put the data in an array within the global and returns the index where the data is set. This index therefore becomes a pointer to the data, and can be used later to set and get data.

The upper 8 bits of the pointer is used as a counter that is incremented by one for each new "dispose pointer" call. The "Get" and "Set" function checks these 8 bits in the pointer with corresponding counter array and throws an error if they are not equal. By doing this an error is thrown when trying to use a disposed pointer. Thanks to JFM for the counter code.

Due to the inherent effectiveness of LV2 style globals and no type conversions, this method is twice as efficient as using queue primitives, see examples provided. Functions such as New, Get, Set etc can be found in the ..\Pointer folder. A project file is also provided for LV 8.x. A more general system that takes arbitrary types is called General Reference System and can be found on this Code repository.

In contrast to queues that can be regarded as synchronous references to data, this reference system is fully asynchronous.

Allocation and freeing of data is done dynamically.

Allthough this pointer system may at first glance have some resemblence to "classic" GOOP, it is by no means a GOOP system. This pointer system is best regarded as a normal LV2 global, but with the difference that it returns a pointer (index) to the data, and therefore can be used for an arbitrary number of data.

All the VIs in the library are documented.

Version History:

1.1.2

Fixed "dispose pointer" and "obtain pointer from pointer". Some other small fixes.

1.1.1

Updated the counter so it will increment at each "dispose pointer" instead of "obtain pointer".

1.1.0

Updated the pointers so that the upper 8 bits is uses as a counter. Using a disposed pointer will therefore create an error. Thanks to JFM.

Updated the allocation routine so 100 elements are added in one chunk. Thanks to JFM.

1.0.1

Updated this readme.txt file

Fixed a bug in "Obtain P from P" function in the global.

Added a placeholder VI (for easier conversion to LV7)

1.0.0:

Initial release of the code.




×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.