summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-08-02 21:32:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-08-02 21:32:21 +0300
commit6d6b04fd4eaf40a4c6a4e2dfa9f0365afb12a2f3 (patch)
treea449678fa20136d41dde722c3b26b21742a23222 /src
parent4c47c97da317d3f4ff233411c212a8ac98847cfa (diff)
Miranda_WaitOnHandleEx - advanced wait function with pInfo parameter
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/miranda.cpp28
3 files changed, 27 insertions, 3 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 2e182da0aa..656bdab2ff 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -629,3 +629,4 @@ Netlib_SetUserSettingsByName @659
?Backup@MDatabaseCommon@@UAGHPB_W@Z @660 NONAME
?addFrame@CMPluginBase@@QAEHPBUCLISTFrame@@@Z @661 NONAME
Menu_SetVisible @662
+Miranda_WaitOnHandleEx @663
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 4bfa9b9ce9..2a08500a71 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -629,3 +629,4 @@ Netlib_SetUserSettingsByName @659
?Backup@MDatabaseCommon@@UEAAHPEB_W@Z @660 NONAME
?addFrame@CMPluginBase@@QEAAHPEBUCLISTFrame@@@Z @661 NONAME
Menu_SetVisible @662
+Miranda_WaitOnHandleEx @663
diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp
index 29ca6bba52..cc7097eb4d 100644
--- a/src/mir_app/src/miranda.cpp
+++ b/src/mir_app/src/miranda.cpp
@@ -81,7 +81,8 @@ struct MWaitableObject
MWaitableObject(MWaitableStub pFunc, HANDLE hEvent) :
m_bOwnsEvent(false),
m_hEvent(hEvent),
- m_pFunc(pFunc)
+ m_pFunc(pFunc),
+ m_pInfo(INVALID_HANDLE_VALUE)
{
if (hEvent == nullptr) {
m_hEvent = CreateEvent(nullptr, TRUE, TRUE, nullptr);
@@ -89,6 +90,13 @@ struct MWaitableObject
}
}
+ MWaitableObject(MWaitableStubEx pFunc, void *pInfo) :
+ m_bOwnsEvent(true),
+ m_hEvent(CreateEvent(nullptr, TRUE, TRUE, nullptr)),
+ m_pFuncEx(pFunc),
+ m_pInfo(pInfo)
+ {}
+
~MWaitableObject()
{
if (m_bOwnsEvent)
@@ -96,7 +104,12 @@ struct MWaitableObject
}
HANDLE m_hEvent;
- MWaitableStub m_pFunc;
+ union {
+ MWaitableStub m_pFunc;
+ MWaitableStubEx m_pFuncEx;
+ };
+ void *m_pInfo;
+
bool m_bOwnsEvent;
};
@@ -107,6 +120,11 @@ MIR_APP_DLL(void) Miranda_WaitOnHandle(MWaitableStub pFunc, HANDLE hEvent)
arWaitableObjects.insert(new MWaitableObject(pFunc, hEvent));
}
+MIR_APP_DLL(void) Miranda_WaitOnHandleEx(MWaitableStubEx pFunc, void *pInfo)
+{
+ arWaitableObjects.insert(new MWaitableObject(pFunc, pInfo));
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// dll entry point
@@ -337,7 +355,11 @@ int WINAPI mir_main(LPTSTR cmdLine)
DWORD rc = myWait();
if (rc < WAIT_OBJECT_0 + arWaitableObjects.getCount()) {
auto &pWait = arWaitableObjects[rc - WAIT_OBJECT_0];
- (*pWait.m_pFunc)();
+ if (pWait.m_pInfo == INVALID_HANDLE_VALUE)
+ (*pWait.m_pFunc)();
+ else
+ (*pWait.m_pFuncEx)(pWait.m_pInfo);
+
if (pWait.m_bOwnsEvent)
arWaitableObjects.remove(&pWait);
}