pEpCOMServerAdapter.h
author Volker Birk <vb@pep-project.org>
Sun, 03 Jul 2016 00:50:41 +0200
changeset 140 3975758c4320
parent 110 c643437f9b61
child 215 033aa489f9d6
permissions -rw-r--r--
don't exit
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@140
    29
        this->Lock(); // never exit
vb@140
    30
vb@110
    31
        try {
vb@110
    32
            gatekeeper_thread = new thread(gatekeeper, this);
vb@110
    33
            gatekeeper_thread->detach();
vb@110
    34
        }
vb@110
    35
        catch (system_error&) {
vb@110
    36
vb@110
    37
        }
vb@110
    38
    }
vb@110
    39
vb@110
    40
protected:
vb@110
    41
    static void gatekeeper(CpEpCOMServerAdapterModule * self);
vb@110
    42
vb@110
    43
private:
vb@110
    44
    thread *gatekeeper_thread;
vb@110
    45
    HMODULE _hModule;
vb@110
    46
};