forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
@ -60,11 +60,6 @@ class MainEvent {
|
||||
|
||||
@:access(haxe.MainEvent)
|
||||
class MainLoop {
|
||||
#if (target.threaded && !cppia)
|
||||
static var eventLoopHandler:Null<EventHandler>;
|
||||
static var mutex = new sys.thread.Mutex();
|
||||
static var mainThread = Thread.current();
|
||||
#end
|
||||
|
||||
static var pending:MainEvent;
|
||||
|
||||
@ -94,7 +89,7 @@ class MainLoop {
|
||||
/**
|
||||
Add a pending event to be run into the main loop.
|
||||
**/
|
||||
public static function add(f:Void->Void, priority = 0):MainEvent@:privateAccess {
|
||||
public static function add(f:Void->Void, priority = 0) : MainEvent {
|
||||
if (f == null)
|
||||
throw "Event function is null";
|
||||
var e = new MainEvent(f, priority);
|
||||
@ -103,29 +98,9 @@ class MainLoop {
|
||||
head.prev = e;
|
||||
e.next = head;
|
||||
pending = e;
|
||||
injectIntoEventLoop(0);
|
||||
return e;
|
||||
}
|
||||
|
||||
static function injectIntoEventLoop(waitMs:Int) {
|
||||
#if (target.threaded && !cppia)
|
||||
mutex.acquire();
|
||||
if(eventLoopHandler != null)
|
||||
mainThread.events.cancel(eventLoopHandler);
|
||||
eventLoopHandler = mainThread.events.repeat(
|
||||
() -> {
|
||||
mainThread.events.cancel(eventLoopHandler);
|
||||
var wait = tick();
|
||||
if(hasEvents()) {
|
||||
injectIntoEventLoop(Std.int(wait * 1000));
|
||||
}
|
||||
},
|
||||
waitMs
|
||||
);
|
||||
mutex.release();
|
||||
#end
|
||||
}
|
||||
|
||||
static function sortEvents() {
|
||||
// pending = haxe.ds.ListSort.sort(pending, function(e1, e2) return e1.nextRun > e2.nextRun ? -1 : 1);
|
||||
// we can't use directly ListSort because it requires prev/next to be public, which we don't want here
|
||||
|
||||
Reference in New Issue
Block a user