summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-01-03 16:03:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-01-03 16:03:40 +0300
commit29b99f947573882bffe0a80ae068afa4d5140fbb (patch)
tree98c45df2a81af8b7dc803f0015ebcbe3fb548247 /src/mir_core
parent2d2166ed2a83bc8ce315f4e7f29c7ab71439a7e4 (diff)
thread-safe implementation of CTimer::Start/Stop
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/CTimer.cpp27
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
3 files changed, 27 insertions, 2 deletions
diff --git a/src/mir_core/src/CTimer.cpp b/src/mir_core/src/CTimer.cpp
index d4df04649a..b0e990e05f 100644
--- a/src/mir_core/src/CTimer.cpp
+++ b/src/mir_core/src/CTimer.cpp
@@ -38,12 +38,35 @@ BOOL CTimer::OnTimer()
return FALSE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct TStartParam
+{
+ CTimer *pTimer;
+ int period;
+};
+
+static INT_PTR CALLBACK stubStart(void *param)
+{
+ auto *p = (TStartParam *)param;
+ return ::SetTimer(p->pTimer->GetHwnd(), p->pTimer->GetEventId(), p->period, nullptr);
+}
+
void CTimer::Start(int elapse)
{
- ::SetTimer(m_wnd->GetHwnd(), m_idEvent, elapse, nullptr);
+ TStartParam param = { this, elapse };
+ CallFunctionSync(stubStart, &param);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static INT_PTR CALLBACK stubStop(void *param)
+{
+ auto *p = (CTimer*)param;
+ return ::KillTimer(p->GetHwnd(), p->GetEventId());
}
void CTimer::Stop()
{
- ::KillTimer(m_wnd->GetHwnd(), m_idEvent);
+ CallFunctionSync(stubStop, this);
}
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 1b22df32d6..8cf65ac054 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1451,3 +1451,4 @@ XmlGetChildText @1645
?Unsigned64Value@XMLAttribute@tinyxml2@@QBE_KXZ @1666 NONAME
?RemoveControl@CDlgBase@@IAEXPAVCCtrlBase@@@Z @1667 NONAME
?assign@MBinBuffer@@QAEXPAXI@Z @1668 NONAME
+?GetHwnd@CTimer@@QBEPAUHWND__@@XZ @1669 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 26b80a6021..ad6aff5753 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1451,3 +1451,4 @@ XmlGetChildText @1645
?Unsigned64Value@XMLAttribute@tinyxml2@@QEBA_KXZ @1666 NONAME
?RemoveControl@CDlgBase@@IEAAXPEAVCCtrlBase@@@Z @1667 NONAME
?assign@MBinBuffer@@QEAAXPEAX_K@Z @1668 NONAME
+?GetHwnd@CTimer@@QEBAPEAUHWND__@@XZ @1669 NONAME