summaryrefslogtreecommitdiffstats
path: root/tools/lldb-mi/MIUtilThreadBaseStd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lldb-mi/MIUtilThreadBaseStd.cpp')
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.cpp b/tools/lldb-mi/MIUtilThreadBaseStd.cpp
index 1cf04fa..2dc6d3d 100644
--- a/tools/lldb-mi/MIUtilThreadBaseStd.cpp
+++ b/tools/lldb-mi/MIUtilThreadBaseStd.cpp
@@ -6,18 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-
-//++
-// File: MIUtilThreadBaseStd.cpp
-//
-// Overview: CMIUtilThread implementation.
-// CMIUtilThreadActiveObjBase implementation.
-// CMIUtilThreadMutex implementation.
-//
-// Environment: Compilers: Visual C++ 12.
-// gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
-// Libraries: See MIReadmetxt.
-//
// Copyright: None.
//--
@@ -217,6 +205,8 @@ CMIUtilThreadActiveObjBase::ThreadManage(void)
// Execute the finish routine just before we die
// to give the object a chance to clean up
ThreadFinish();
+
+ m_thread.Finish();
}
//---------------------------------------------------------------------------------------
@@ -226,6 +216,7 @@ CMIUtilThreadActiveObjBase::ThreadManage(void)
//
CMIUtilThread::CMIUtilThread(void)
: m_pThread(nullptr)
+ , m_bIsActive(false)
{
}
@@ -278,12 +269,24 @@ CMIUtilThread::Join(void)
bool
CMIUtilThread::IsActive(void)
{
- // Lock while we access the thread pointer
+ // Lock while we access the thread status
+ CMIUtilThreadLock _lock(m_mutex);
+ return m_bIsActive;
+}
+
+//++ ------------------------------------------------------------------------------------
+// Details: Finish this thread
+// Type: Method.
+// Args: None.
+// Return: None.
+// Throws: None.
+//--
+void
+CMIUtilThread::Finish(void)
+{
+ // Lock while we access the thread status
CMIUtilThreadLock _lock(m_mutex);
- if (m_pThread == nullptr)
- return false;
- else
- return true;
+ m_bIsActive = false;
}
//++ ------------------------------------------------------------------------------------
@@ -298,8 +301,12 @@ CMIUtilThread::IsActive(void)
bool
CMIUtilThread::Start(FnThreadProc vpFn, void *vpArg)
{
- // Create the std thread, which starts immediately
+ // Lock while we access the thread pointer and status
+ CMIUtilThreadLock _lock(m_mutex);
+
+ // Create the std thread, which starts immediately and update its status
m_pThread = new std::thread(vpFn, vpArg);
+ m_bIsActive = true;
// We expect to always be able to create one
assert(m_pThread != nullptr);
OpenPOWER on IntegriCloud