summaryrefslogtreecommitdiff
path: root/source/utilities/CaptiveThreadObject.h
blob: 9fdcdaec65c50415b4f44d92e3c7240b4c556dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************************************
*
*    File name: CaptiveThreadObject.h
*     Language: Visual C++
*  Description: Captive Thread Object class declarations
*
*
* Copyright (C) ST-Ericsson SA 2011
* License terms: 3-clause BSD license
*
*******************************************************************************/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                            File CaptiveThreadObject.h

#ifndef __CAPTIVE_THREAD_OBJECT_H__
#define __CAPTIVE_THREAD_OBJECT_H__

#pragma once

#if defined(WIN32)
#include <windows.h>
#include "WinApiWrappers.h"
#elif (defined(__linux__) || defined(__APPLE__))
#include "LinuxApiWrappers.h"
#else
#error "Unknown target"
#endif

// CCaptiveThreadObject owns the captive thread
class CCaptiveThreadObject
{
public:
    CCaptiveThreadObject();
    virtual ~CCaptiveThreadObject();
    void EndCaptiveThread();
    int ThreadIsDying() {
        return IsDying;
    }
protected:
    virtual void InitializeCaptiveThreadObject() = 0;
    virtual void MainExecutionLoop() = 0;

    virtual void SignalDeath() = 0;
#ifdef _WIN32
    static unsigned int WINAPI ThreadEntry(void *arg);
#else
    static void *ThreadEntry(void *arg);
#endif
    int IsDying;
    CThreadWrapper  Thread;
};

#endif

//                                                                                     End of file CaptiveThreadObject.h
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////