diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 0c65698760..d7e565b98d 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2287,10 +2287,16 @@ thread_base::~thread_base() } } -bool thread_base::join() const +bool thread_base::join(bool dtor) const { + // Check if already finished + if (m_sync & 2) + { + return (m_sync & 3) == 3; + } + // Hacked for too sleepy threads (1ms) TODO: make sure it's unneeded and remove - const auto timeout = Emu.IsStopped() ? atomic_wait_timeout{1'000'000} : atomic_wait_timeout::inf; + const auto timeout = dtor && Emu.IsStopped() ? atomic_wait_timeout{1'000'000} : atomic_wait_timeout::inf; bool warn = false; auto stamp0 = __rdtsc(); diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 48b1b0eec2..2763cce1c8 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -142,7 +142,7 @@ public: u64 get_cycles(); // Wait for the thread (it does NOT change thread state, and can be called from multiple threads) - bool join() const; + bool join(bool dtor = false) const; // Notify the thread void notify(); @@ -393,7 +393,7 @@ public: { // Assign aborting state forcefully operator=(thread_state::aborting); - thread::join(); + thread::join(true); if constexpr (!result::empty) { diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 51cb8f9686..0c96a2b761 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -369,7 +369,7 @@ int main(int argc, char** argv) #endif // Initialize thread pool finalizer (on first use) - named_thread("", []{}); + named_thread("", []{})(); std::unique_ptr log_file; {