mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Modernize Thread
- Based on C++11's `thread` and `thread_local` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed (except for the few cases of non-portable functions) - Simpler for `NO_THREADS` - Thread ids are now the same across platforms (main is 1; others follow)
This commit is contained in:
@@ -65,12 +65,8 @@ int RemoteDebuggerPeerTCP::get_max_message_size() const {
|
||||
}
|
||||
|
||||
void RemoteDebuggerPeerTCP::close() {
|
||||
if (thread) {
|
||||
running = false;
|
||||
Thread::wait_to_finish(thread);
|
||||
memdelete(thread);
|
||||
thread = nullptr;
|
||||
}
|
||||
running = false;
|
||||
thread.wait_to_finish();
|
||||
tcp_client->disconnect_from_host();
|
||||
out_buf.resize(0);
|
||||
in_buf.resize(0);
|
||||
@@ -85,7 +81,7 @@ RemoteDebuggerPeerTCP::RemoteDebuggerPeerTCP(Ref<StreamPeerTCP> p_tcp) {
|
||||
connected = true;
|
||||
#ifndef NO_THREADS
|
||||
running = true;
|
||||
thread = Thread::create(_thread_func, this);
|
||||
thread.start(_thread_func, this);
|
||||
#endif
|
||||
} else {
|
||||
tcp_client.instance();
|
||||
@@ -188,7 +184,7 @@ Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_po
|
||||
connected = true;
|
||||
#ifndef NO_THREADS
|
||||
running = true;
|
||||
thread = Thread::create(_thread_func, this);
|
||||
thread.start(_thread_func, this);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user