I have a for loop inside a while (1) and I want the loop to average approx 2 minutes through each entire for loop cycle. This requires sleeping between each iteration for a different time based on execution time of the iteration and time remaining in my 2 minute shot clock. Any ideas.
I was moving towards something
while(true)
{
unsigned long begin_loop = OCX::micro_stamp();
for (int i = 0; i < _vector.size(); i++)
{
unsigned long start = OCX::micro_stamp();
unsigned long avg = ( ( begin_loop - start) / ( i + 1 ) );
usleep ( ( 120000000 - ( (_vector.size() - i) * avg ) ) / ( _vector.size() - i ) );
try
{
}
catch {
}
}
}