more gc blocking

This commit is contained in:
RandomityGuy 2024-05-28 20:13:42 +05:30
parent 0dc21e577a
commit d681c2aa5f
2 changed files with 22 additions and 2 deletions

View file

@ -26,17 +26,26 @@ class MasterServerClient {
#if hl
var wsThread:sys.thread.Thread;
static var responses:sys.thread.Deque<() -> Void> = new sys.thread.Deque<() -> Void>();
var toSend:sys.thread.Deque<String> = new sys.thread.Deque<String>();
var stopping:Bool = false;
var stopMutex: sys.thread.Mutex = new sys.thread.Mutex();
var stopMutex:sys.thread.Mutex = new sys.thread.Mutex();
#end
public function new(onOpenFunc:() -> Void) {
#if hl
wsThread = sys.thread.Thread.create(() -> {
hl.Gc.enable(false);
hl.Gc.blocking(true); // Wtf is this shit
#end
ws = WebSocket.create(serverIp);
#if hl
hl.Gc.enable(true);
hl.Gc.blocking(false);
#end
ws.onopen = () -> {
open = true;
#if hl
@ -98,10 +107,22 @@ class MasterServerClient {
var s = toSend.pop(false);
if (s == null)
break;
#if hl
hl.Gc.blocking(true);
#end
ws.sendString(s);
#if hl
hl.Gc.blocking(false);
#end
}
#if hl
hl.Gc.blocking(true);
#end
ws.process();
#if hl
hl.Gc.blocking(false);
#end
stopMutex.release();
Sys.sleep(0.1);
}

View file

@ -87,7 +87,6 @@ class Net {
"stun:stun2.l.google.com:19302",
"stun:stun3.l.google.com:19302",
"stun:stun4.l.google.com:19302",
"stun:relay.metered.ca:80",
];
public static var turnServer:String = "";