From f7e95217e936da34d7124aaced590692eb515923 Mon Sep 17 00:00:00 2001 From: Viktor Mladenovski Date: Fri, 20 May 2011 14:10:59 +0200 Subject: Initial contribution of loader_communication ST-Ericsson ID: 326913 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I171cfc2ee458a8a0a91a1916137d131f0f7ecee5 --- source/utilities/CaptiveThreadObject.cpp | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 source/utilities/CaptiveThreadObject.cpp (limited to 'source/utilities/CaptiveThreadObject.cpp') 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(arg); + pThis->InitializeCaptiveThreadObject(); + pThis->MainExecutionLoop(); + return 0; +} +// End of file CaptiveThreadObject.cpp +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3