Default Re: Reading _Lock hangs????
Reading _Lock is especially tricky
There are no indexes on VSTs and they mostly mirror C data structures rather than actual database tables. Many VSTs (including _Lock) should be read in a manner that excludes key values of ? as these indicate unused entries in fixed arrays inside the db engine.
To read _Lock relatively efficiently use code similar to this:
for each _lock no-lock while _lock-usr <> ?:
/* do something with _lock records... */
Note the unusual usage of WHILE rather than WHERE in the FOR EACH. This is an important detail for the _lock VST.
_Lock is also problematic because the number of entries in use can change very rapidly. Your code may seem very well behaved under normal conditions but under the circumstances when people sometimes get interested in locks (i.e. when there are a great many of them) it all goes to pieces… Reading _lock can be painfully slow when there are lots of entries. Even with the code above (which is as good as it gets…)
For more insights into programming VSTs check out: