In article <50650000000800000033720000-1042324653000@exchange.ni.com>,
"Craig Leidholm" wrote:
> How can I remember the iteration number of a while loop to access it in
> the unknown future. Shift registers are good for a few iterations
> backward, but what about 200 iterations back, or a variable number of
> iterations back?
>
> Thanks.
Hi Craig,
"unknown future" makes me nervous. That just screams memory leak so you
have to be careful what and how much you log or track. I think your best
bet is to use Queues. I guess that you're gathering and then monitoring
some data with each iteration. You can add questionable data and the
iteration it was collected into a queue object and dump it after the loop
is completed. The other option is to fill
the queue with n samples
(dependent upon memory limitations) and then when it reaches the limit
your app can analyze the contents to determine whether you should continue
or not. Either way, with queues you can set a cap on its size when you
initialize it. When it reaches the cap your loop will have to stop as it
tries to add data to the queue because it's full. This prevents your
memory from getting used up and crashing or freezing your app. You can
do a similar thing with an arrayed cluster but the memory cap will have
to be mainained by your app.
You may want to use a combination of synchronization techniques. Hope
this helps.
- Kevin