-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create Timer for neko/cpp when NME/OpenFL are not used #3
Comments
From Hugh on the ML: I guess the first question is do you want sync or async timer callbacks? Sync is probably the most "cross platform" way. I think the haxe timer class could easily be extended for non event driver apps by having a function "processTimers()". So like this: public static function main() {
var count = 10;
Timer.delay(function() trace("Hi"), 1000 );
Timer.processTimers();
} And a sync processTimers can be created without any threads, by creating a list of pending timers. public static function processTimers() {
while(true) {
var nextTimer = findNextTimer(); // Get one with least due time
if (nextTimer==null)
break;
var delay = nextTimer.due - stamp();
if (delay>0)
sleep(delay);
nextTimer.run();
}
} Whether you want to automagically call processTimers() via macro or otherwise is a minor matter, but explicit calling is not that hard. |
No description provided.
The text was updated successfully, but these errors were encountered: