Skip to content

Commit

Permalink
dum
Browse files Browse the repository at this point in the history
  • Loading branch information
Snirozu committed Nov 17, 2023
1 parent df0a2a4 commit 1d42f6b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/online/Waiter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import flixel.FlxBasic;
//thread safe function handler
class Waiter extends FlxBasic {
public static var queue:Array<Void->Void> = [];
var _queueItem:Void->Void;

public static function put(func:Void->Void) {
queue.push(func);
Expand All @@ -13,10 +14,12 @@ class Waiter extends FlxBasic {
override function update(elapsed) {
super.update(elapsed);

for (_ in queue) {
if (queue.shift() != null) {
_();
};
while (queue.length > 0) {
_queueItem = queue.shift();

if (_queueItem != null) {
_queueItem();
}
}
}
}

0 comments on commit 1d42f6b

Please sign in to comment.