Page 1 of 1
yrest
Posted: Tue Sep 02, 2008 7:50 pm
by luonline
Code: Select all
function yrest(msec)
safeYield();
if( msec < 10 ) then (1)
rest(msec);
return;
else
sections = math.floor(msec / 100); -- split into 10msec sections (2)
...
end
Taking a closer look at this code in lib.lua, I think:
(1) this line should be "if( msec < 100 ) then"
(2) this comment should be "-- split into 100msec sections"
Right?
Re: yrest
Posted: Wed Sep 03, 2008 2:45 pm
by Administrator
You're absolutely right. I think I screwed that up when I was trying to split it into 10ms sections instead of 100, but then it caused some problems (yielding across C-boundaries). I'll rework it to allow 10ms sections if Coco is available, or fall back on 100ms sections otherwise.
Thanks for the bug report.
Re: yrest
Posted: Wed Sep 03, 2008 3:16 pm
by luonline
elverion wrote:Thanks for the bug report.
Forget about it.
Actually, we (all users) thank you for spending your time developing and improving this great tool!
Re: yrest
Posted: Thu Sep 04, 2008 6:55 am
by luonline
elverion wrote:I'll rework it to allow 10ms sections if Coco is available, or fall back on 100ms sections otherwise.
Just a suggestion of implementation:
Code: Select all
function yrest(msec)
safeYield();
local size;
if( cocoAvailable ) then
size = 10;
else
size = 100;
end
if( msec < size ) then
rest(msec);
return;
else
sections = math.floor(msec / size); -- split into sections
ext = math.mod(msec, size); -- any left overs...
for b = 1,sections do
rest(size);
safeYield();
end;
if( ext > 0 ) then
rest(ext);
end
end
end
Of course, it should be tested regarding those problems (yielding across C-boundaries).