pEpCOMServerAdapter.h
author Thomas
Wed, 02 May 2018 09:46:48 +0200
branchCOM-87
changeset 287 99abd7d70c1e
parent 215 033aa489f9d6
permissions -rw-r--r--
Rename flags
vb@110
     1
#include "stdafx.h"
vb@110
     2
vb@110
     3
#include "pEpCOMServerAdapter_i.h"
vb@110
     4
vb@110
     5
using namespace ATL;
vb@110
     6
using namespace std;
vb@110
     7
vb@110
     8
class CpEpCOMServerAdapterModule : public ATL::CAtlExeModuleT< CpEpCOMServerAdapterModule > {
vb@110
     9
public:
vb@110
    10
    CpEpCOMServerAdapterModule() : ATL::CAtlExeModuleT< CpEpCOMServerAdapterModule >(), gatekeeper_thread(NULL), _hModule(NULL)
vb@110
    11
    {
vb@110
    12
    }
vb@110
    13
vb@110
    14
    DECLARE_LIBID(LIBID_pEpCOMServerAdapterLib)
vb@110
    15
    DECLARE_REGISTRY_APPID_RESOURCEID(IDR_PEPCOMSERVERADAPTER, "{B3480081-82C0-4EE4-9AA1-3F513C9D78DD}")
vb@110
    16
vb@110
    17
    HMODULE hModule()
vb@110
    18
    {
vb@110
    19
        return _hModule;
vb@110
    20
    }
vb@110
    21
vb@110
    22
    void hModule(HMODULE m)
vb@110
    23
    {
vb@110
    24
        _hModule = m;
vb@110
    25
    }
vb@110
    26
vb@110
    27
    void start_gatekeeper()
vb@110
    28
    {
vb@215
    29
#ifdef NDEBUG
vb@140
    30
        this->Lock(); // never exit
vb@215
    31
#endif
vb@140
    32
vb@110
    33
        try {
vb@110
    34
            gatekeeper_thread = new thread(gatekeeper, this);
vb@110
    35
            gatekeeper_thread->detach();
vb@110
    36
        }
vb@110
    37
        catch (system_error&) {
vb@110
    38
vb@110
    39
        }
vb@110
    40
    }
vb@110
    41
vb@110
    42
protected:
vb@110
    43
    static void gatekeeper(CpEpCOMServerAdapterModule * self);
vb@110
    44
vb@110
    45
private:
vb@110
    46
    thread *gatekeeper_thread;
vb@110
    47
    HMODULE _hModule;
vb@110
    48
};