Implement join with timeout (and detach).

Under certain situations (notably JNI shutdown), it's possible to get
deadlock when using thread join().  To avoid this, implement a timeout.
Normally we try to simply join the thread, but if it times out, we
detach the thread instead.
This commit is contained in:
Peter Johnson
2015-10-09 23:50:01 -07:00
parent d77b3d788e
commit dd0e3e4abb
8 changed files with 166 additions and 12 deletions

View File

@@ -99,6 +99,13 @@ class DispatcherBase {
std::condition_variable m_reconnect_cv;
unsigned int m_reconnect_proto_rev = 0x0300;
bool m_do_reconnect = true;
// Condition variables for shutdown
std::mutex m_shutdown_mutex;
std::condition_variable m_dispatch_shutdown_cv;
std::condition_variable m_clientserver_shutdown_cv;
bool m_dispatch_shutdown = false;
bool m_clientserver_shutdown = false;
};
class Dispatcher : public DispatcherBase {