In other words I want to do something like this:
Code: Select all
local startTime = os.clock()
for key,value in pairs(someReallyLongTable) do
-- some relatively quick operation on key/value
if os.clock() - startTime > 100 then
coroutine.yield()
startTime = os.clock()
end
end
The problem is, PA doesn't seem to give lua scripts access to the os.clock() function, and I'm not sure if there's a reasonable alternative. I can of course go by the number of iterations through the loop, but the time based approach is more ideal, as it can scale according to the power of the user's processor.