From c55bee1961b51c61266e38eda13132e0ef7ae11a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 1 Feb 2020 15:51:23 +0300 Subject: attempt to fix #2139 --- src/mir_core/src/locks.cpp | 46 +++++++++++++++++++++++++++++++++++++++++ src/mir_core/src/mir_core.def | 5 +++++ src/mir_core/src/mir_core64.def | 5 +++++ 3 files changed, 56 insertions(+) create mode 100644 src/mir_core/src/locks.cpp (limited to 'src') diff --git a/src/mir_core/src/locks.cpp b/src/mir_core/src/locks.cpp new file mode 100644 index 0000000000..2a53d0051a --- /dev/null +++ b/src/mir_core/src/locks.cpp @@ -0,0 +1,46 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (C) 2012-20 Miranda NG team (https://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" + +mir_cs::mir_cs() +{ + ::InitializeCriticalSection(&m_cs); +} + +mir_cs::~mir_cs() +{ + ::DeleteCriticalSection(&m_cs); +} + +void mir_cs::Lock() +{ + while (!::TryEnterCriticalSection(&m_cs)) + ::SleepEx(50, TRUE); +} + +void mir_cs::Unlock() +{ + ::LeaveCriticalSection(&m_cs); +} diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 7254c631aa..d233b605ec 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1452,3 +1452,8 @@ XmlGetChildText @1645 ?RemoveControl@CDlgBase@@IAEXPAVCCtrlBase@@@Z @1667 NONAME ?assign@MBinBuffer@@QAEXPAXI@Z @1668 NONAME ?GetHwnd@CTimer@@QBEPAUHWND__@@XZ @1669 NONAME +??0MNonCopyable@@QAE@XZ @1670 NONAME +??0mir_cs@@QAE@XZ @1671 NONAME +??1mir_cs@@QAE@XZ @1672 NONAME +?Lock@mir_cs@@QAEXXZ @1673 NONAME +?Unlock@mir_cs@@QAEXXZ @1674 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 1aca6aa620..b589947f72 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1452,3 +1452,8 @@ XmlGetChildText @1645 ?RemoveControl@CDlgBase@@IEAAXPEAVCCtrlBase@@@Z @1667 NONAME ?assign@MBinBuffer@@QEAAXPEAX_K@Z @1668 NONAME ?GetHwnd@CTimer@@QEBAPEAUHWND__@@XZ @1669 NONAME +??0MNonCopyable@@QEAA@XZ @1670 NONAME +??0mir_cs@@QEAA@XZ @1671 NONAME +??1mir_cs@@QEAA@XZ @1672 NONAME +?Lock@mir_cs@@QEAAXXZ @1673 NONAME +?Unlock@mir_cs@@QEAAXXZ @1674 NONAME -- cgit v1.2.3