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
No known key found for this signature in database
GPG Key ID: A32174A3D2ED3F9E
2 changed files with 4 additions and 4 deletions

View File

@ -32,7 +32,7 @@
void EditorHTTPServer::_server_thread_poll(void *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);
{
MutexLock lock(web_server->server_lock);
@ -193,7 +193,7 @@ void EditorHTTPServer::_poll() {
}
void EditorHTTPServer::stop() {
server_quit.set(true);
server_quit.set();
if (server_thread.is_started()) {
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);
if (err == OK) {
server_quit.set(false);
server_quit.clear();
server_thread.start(_server_thread_poll, this);
}
return err;

View File

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