summaryrefslogtreecommitdiff
path: root/source/utilities/CaptiveThreadObject.cpp
diff options
context:
space:
mode:
authorViktor Mladenovski <viktor.mladenovski@stericsson.com>2011-05-20 14:10:59 +0200
committerViktor Mladenovski <viktor.mladenovski@stericsson.com>2011-05-20 14:10:59 +0200
commitf7e95217e936da34d7124aaced590692eb515923 (patch)
tree2d9ef4750a67d9d1dd3fe9180a4fef2929fad54b /source/utilities/CaptiveThreadObject.cpp
Initial contribution of loader_communication
ST-Ericsson ID: 326913 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I171cfc2ee458a8a0a91a1916137d131f0f7ecee5
Diffstat (limited to 'source/utilities/CaptiveThreadObject.cpp')
-rw-r--r--source/utilities/CaptiveThreadObject.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/utilities/CaptiveThreadObject.cpp b/source/utilities/CaptiveThreadObject.cpp
new file mode 100644
index 0000000..e9eb472
--- /dev/null
+++ b/source/utilities/CaptiveThreadObject.cpp
@@ -0,0 +1,51 @@
+/*******************************************************************************
+*
+* File name: CaptiveThreadObject.cpp
+* Language: Visual C++
+* Description: Captive Thread Object class definitions
+*
+*
+* Copyright (C) ST-Ericsson SA 2011
+* License terms: 3-clause BSD license
+*
+*******************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File CaptiveThreadObject.cpp
+
+#include "CaptiveThreadObject.h"
+
+CCaptiveThreadObject::CCaptiveThreadObject()
+ : IsDying(0),
+#pragma warning(disable: 4355) // 'this' used before initialized but ok as thread starts in inactive state
+ Thread(ThreadEntry, this)
+{
+}
+#pragma warning(default: 4355)
+
+CCaptiveThreadObject::~CCaptiveThreadObject()
+{
+}
+
+void CCaptiveThreadObject::EndCaptiveThread()
+{
+ IsDying++;
+ SignalDeath();
+ Thread.WaitToDie();
+}
+
+
+// ThreadEntry - Entry point, executed by captive thread
+#ifdef _WIN32
+unsigned int WINAPI CCaptiveThreadObject::ThreadEntry(void *arg)
+#else
+void *CCaptiveThreadObject::ThreadEntry(void *arg)
+#endif
+{
+ CCaptiveThreadObject *pThis = static_cast<CCaptiveThreadObject *>(arg);
+ pThis->InitializeCaptiveThreadObject();
+ pThis->MainExecutionLoop();
+ return 0;
+}
+// End of file CaptiveThreadObject.cpp
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////