diff options
Diffstat (limited to 'source/utilities/CaptiveThreadObject.cpp')
-rw-r--r-- | source/utilities/CaptiveThreadObject.cpp | 51 |
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 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |