LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you create a reentrant subVI whose instance is accessible using a refnum?

I am trying to create a hash table similar to the one create on the thread http://forums.ni.com/ni/board/message?board.id=170&thread.id=136037&view=by_date_ascending&page=2. That hash table uses unintialized shift registers to store the hash table data. The implementation only works for one hash table because if the function was made reentrant, there would be no way to access a specific hash table instance to perform operations. I am trying to write a hash table that is renentrant but with instaces accessible via a refnum. Currently, I am using a different subVI for each operation in a hash table class and passing a hash table cluster among the subVIs, but the bundling and unbundling induces too much of a performance hit.
0 Kudos
Message 1 of 2
(2,521 Views)

You can do this by opening a reference to the subVI and then running it using a call by reference node. You can see an example here. Just note that you have to set an option on the open primitive to prepare the VI for reentrant execution (I think it's 2 or 8, can't remember).

If you want to see a more complete implementation, you can try downloading the OpenGOOP framework from OpenG, which uses this mechanism for data storage. Alternatively, you can use a queue to pass the data. If you have a single element in the queue and always make sure to dequeue and then re-enqueue, you should get a single copy of the data in memory.

You can also use variant attributes to do the lookup table. You can see more here.


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(2,497 Views)