Merge pull request #88155 from Rubonnek/use-safeflag-instead

Use `SafeFlag` for `EditorHTTPServer.server_quit`
This commit is contained in:
Rémi Verschelde 2024-02-12 13:34:41 +01:00
commit ed7f1186a6
No known key found for this signature in database
GPG Key ID: C3336907360768E1
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;