Fix up the HostThread interface, making the interface simpler.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5417
llvm-svn: 218325
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 6a39736..20ac736 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1396,7 +1396,7 @@
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
NativeProcessLinux::MonitorCallback, this, GetID(), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError();
error.SetErrorString ("Process attach failed to create monitor thread for NativeProcessLinux::MonitorCallback.");
@@ -1474,7 +1474,7 @@
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess (
NativeProcessLinux::MonitorCallback, this, GetID (), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError ();
error.SetErrorString ("Process attach failed to create monitor thread for NativeProcessLinux::MonitorCallback.");
@@ -1495,7 +1495,7 @@
{
static const char *g_thread_name = "lldb.process.nativelinux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
@@ -1804,7 +1804,7 @@
{
static const char *g_thread_name = "lldb.process.linux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
@@ -3645,11 +3645,10 @@
void
NativeProcessLinux::StopMonitoringChildProcess()
{
- if (m_monitor_thread.GetState() == eThreadStateRunning)
+ if (m_monitor_thread.IsJoinable())
{
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
- m_monitor_thread.Reset();
}
}
@@ -3671,12 +3670,11 @@
void
NativeProcessLinux::StopOpThread()
{
- if (m_operation_thread.GetState() != eThreadStateRunning)
+ if (!m_operation_thread.IsJoinable())
return;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
- m_operation_thread.Reset();
}
bool
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
index 99d14d2..8f626be 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -1199,7 +1199,7 @@
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError();
error.SetErrorString("Process launch failed.");
@@ -1250,7 +1250,7 @@
// Finally, start monitoring the child process for change in state.
m_monitor_thread = Host::StartMonitoringChildProcess(
ProcessMonitor::MonitorCallback, this, GetPID(), true);
- if (m_monitor_thread.GetState() != eThreadStateRunning)
+ if (!m_monitor_thread.IsJoinable())
{
error.SetErrorToGenericError();
error.SetErrorString("Process attach failed.");
@@ -1270,7 +1270,7 @@
{
static const char *g_thread_name = "lldb.process.linux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
@@ -1493,7 +1493,7 @@
{
static const char *g_thread_name = "lldb.process.linux.operation";
- if (m_operation_thread.GetState() == eThreadStateRunning)
+ if (m_operation_thread.IsJoinable())
return;
m_operation_thread = ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
@@ -2466,11 +2466,10 @@
void
ProcessMonitor::StopMonitoringChildProcess()
{
- if (m_monitor_thread.GetState() == eThreadStateRunning)
+ if (m_monitor_thread.IsJoinable())
{
m_monitor_thread.Cancel();
m_monitor_thread.Join(nullptr);
- m_monitor_thread.Reset();
}
}
@@ -2491,10 +2490,9 @@
void
ProcessMonitor::StopOpThread()
{
- if (m_operation_thread.GetState() != eThreadStateRunning)
+ if (!m_operation_thread.IsJoinable())
return;
m_operation_thread.Cancel();
m_operation_thread.Join(nullptr);
- m_operation_thread.Reset();
}