1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Use SafeFlag for EditorHTTPServer.server_quit

This commit is contained in:
Wilson E. Alvarez
2024-02-09 14:35:32 -05:00
parent 4e990cd7e5
commit c32e48890f
2 changed files with 4 additions and 4 deletions

View File

@@ -32,7 +32,7 @@
void EditorHTTPServer::_server_thread_poll(void *data) { void EditorHTTPServer::_server_thread_poll(void *data) {
EditorHTTPServer *web_server = static_cast<EditorHTTPServer *>(data); EditorHTTPServer *web_server = static_cast<EditorHTTPServer *>(data);
while (!web_server->server_quit.get()) { while (!web_server->server_quit.is_set()) {
OS::get_singleton()->delay_usec(6900); OS::get_singleton()->delay_usec(6900);
{ {
MutexLock lock(web_server->server_lock); MutexLock lock(web_server->server_lock);
@@ -193,7 +193,7 @@ void EditorHTTPServer::_poll() {
} }
void EditorHTTPServer::stop() { void EditorHTTPServer::stop() {
server_quit.set(true); server_quit.set();
if (server_thread.is_started()) { if (server_thread.is_started()) {
server_thread.wait_to_finish(); server_thread.wait_to_finish();
} }
@@ -227,7 +227,7 @@ Error EditorHTTPServer::listen(int p_port, IPAddress p_address, bool p_use_tls,
} }
Error err = server->listen(p_port, p_address); Error err = server->listen(p_port, p_address);
if (err == OK) { if (err == OK) {
server_quit.set(false); server_quit.clear();
server_thread.start(_server_thread_poll, this); server_thread.start(_server_thread_poll, this);
} }
return err; return err;

View File

@@ -51,7 +51,7 @@ private:
uint8_t req_buf[4096]; uint8_t req_buf[4096];
int req_pos = 0; int req_pos = 0;
SafeNumeric<bool> server_quit; SafeFlag server_quit;
Mutex server_lock; Mutex server_lock;
Thread server_thread; Thread server_thread;