diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-13 10:50:59 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-13 10:50:59 +0000 |
commit | 5df94ff719eccd04c7450df35fb5e3f2b36e2ee7 (patch) | |
tree | 440d736b199ff849ca0619adf355ffc73750ca7f /src | |
parent | 70496fb739225b559a251f4518c946110aef718c (diff) |
wrapping the most evident critical sections into a class
git-svn-id: http://svn.miranda-ng.org/main/trunk@9785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/modules.cpp | 2 | ||||
-rw-r--r-- | src/modules/button/button.cpp | 14 | ||||
-rw-r--r-- | src/modules/chat/chat.h | 2 | ||||
-rw-r--r-- | src/modules/chat/chat_svc.cpp | 5 | ||||
-rw-r--r-- | src/modules/clist/genmenu.cpp | 13 | ||||
-rw-r--r-- | src/modules/database/database.h | 2 | ||||
-rw-r--r-- | src/modules/database/mdatabasecache.cpp | 2 | ||||
-rw-r--r-- | src/modules/icolib/IcoLib.h | 2 | ||||
-rw-r--r-- | src/modules/icolib/skin2icons.cpp | 4 | ||||
-rw-r--r-- | src/modules/netlib/netlib.cpp | 4 | ||||
-rw-r--r-- | src/modules/netlib/netlib.h | 2 | ||||
-rw-r--r-- | src/modules/netlib/netlibopenconn.cpp | 2 |
12 files changed, 13 insertions, 41 deletions
diff --git a/src/core/modules.cpp b/src/core/modules.cpp index cea9906330..69da44111a 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -67,7 +67,6 @@ int LoadDefaultServiceModePlugin(void); int LoadErrorsModule(void);
void UnloadAccountsModule(void);
-void UnloadButtonModule(void);
void UnloadClcModule(void);
void UnloadContactListModule(void);
void UnloadDatabase(void);
@@ -181,7 +180,6 @@ void UnloadDefaultModules(void) UnloadIcoLibModule();
UnloadUtilsModule();
UnloadExtraIconsModule();
- UnloadButtonModule();
UnloadClcModule();
UnloadContactListModule();
UnloadEventsModule();
diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index b79a0386c8..efe2c397b2 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -36,7 +36,7 @@ struct TTooltips };
static LIST<TTooltips> lToolTips(1, NumericKeySortT);
-static CRITICAL_SECTION csTips;
+static mir_cs csTips;
static BOOL bModuleInitialized = FALSE;
// Used for our own cheap TrackMouseEvent
@@ -627,17 +627,5 @@ int LoadButtonModule(void) RegisterClassEx(&wc);
CreateServiceFunction("Button/GetWindowProc", GetButtonProc);
- InitializeCriticalSection(&csTips);
return 0;
}
-
-///////////////////////////////////////////////////////////////////////////////
-// Module unload
-
-void UnloadButtonModule()
-{
- if (!bModuleInitialized)
- return;
-
- DeleteCriticalSection(&csTips);
-}
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h index fbe96ac805..1ba8c46f69 100644 --- a/src/modules/chat/chat.h +++ b/src/modules/chat/chat.h @@ -39,7 +39,7 @@ extern HGENMENU hJoinMenuItem, hLeaveMenuItem; extern GlobalLogSettingsBase *g_Settings;
extern int g_cbSession, g_cbModuleInfo, g_iFontMode, g_iChatLang;
extern TCHAR *g_szFontGroup;
-extern CRITICAL_SECTION cs;
+extern mir_cs cs;
extern PBYTE pLogIconBmpBits[14];
extern int logIconBmpSize[14];
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index 1239b624b0..211e913d83 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -27,7 +27,7 @@ INT_PTR SvcGetChatManager(WPARAM, LPARAM); #include "chat.h"
HGENMENU hJoinMenuItem, hLeaveMenuItem;
-CRITICAL_SECTION cs;
+mir_cs cs;
static HANDLE
hServiceRegister = NULL,
@@ -583,8 +583,6 @@ static bool bInited = false; int LoadChatModule(void)
{
- InitializeCriticalSection(&cs);
-
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
@@ -620,7 +618,6 @@ void UnloadChatModule(void) FreeMsgLogBitmaps();
OptionsUnInit();
- DeleteCriticalSection(&cs);
DestroyHookableEvent(ci.hSendEvent);
DestroyHookableEvent(ci.hBuildMenuEvent);
diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index 0014545c27..3cf0a71c6d 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static bool bIsGenMenuInited;
bool bIconsDisabled;
-static CRITICAL_SECTION csMenuHook;
+static mir_cs csMenuHook;
static int NextObjectId = 0x100, NextObjectMenuItemId = CLISTMENUIDMIN;
@@ -1150,7 +1150,6 @@ static INT_PTR SRVMO_SetOptionsMenuItem(WPARAM, LPARAM lParam) int InitGenMenu()
{
- InitializeCriticalSection(&csMenuHook);
CreateServiceFunction(MO_BUILDMENU, MO_BuildMenu);
CreateServiceFunction(MO_PROCESSCOMMAND, (MIRANDASERVICE)MO_ProcessCommand);
@@ -1181,13 +1180,9 @@ int InitGenMenu() int UnitGenMenu()
{
if (bIsGenMenuInited) {
- {
- mir_cslock lck(csMenuHook);
- MO_RemoveAllObjects();
- bIsGenMenuInited = false;
- }
-
- DeleteCriticalSection(&csMenuHook);
+ mir_cslock lck(csMenuHook);
+ MO_RemoveAllObjects();
+ bIsGenMenuInited = false;
}
return 0;
}
diff --git a/src/modules/database/database.h b/src/modules/database/database.h index 286c651c02..7f581b341b 100644 --- a/src/modules/database/database.h +++ b/src/modules/database/database.h @@ -26,7 +26,7 @@ class MDatabaseCache : public MIDatabaseCache HANDLE m_hCacheHeap;
char* m_lastSetting;
DBCachedContact *m_lastVL;
- CRITICAL_SECTION m_cs;
+ mir_cs m_cs;
LIST<DBCachedContact> m_lContacts;
LIST<DBCachedGlobalValue> m_lGlobalSettings;
diff --git a/src/modules/database/mdatabasecache.cpp b/src/modules/database/mdatabasecache.cpp index c688a2efa4..7944a6bc86 100644 --- a/src/modules/database/mdatabasecache.cpp +++ b/src/modules/database/mdatabasecache.cpp @@ -40,13 +40,11 @@ MDatabaseCache::MDatabaseCache() : m_lGlobalSettings(50, compareGlobals)
{
m_hCacheHeap = HeapCreate(0, 0, 0);
- InitializeCriticalSection(&m_cs);
}
MDatabaseCache::~MDatabaseCache()
{
HeapDestroy(m_hCacheHeap);
- DeleteCriticalSection(&m_cs);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/modules/icolib/IcoLib.h b/src/modules/icolib/IcoLib.h index d743e0e4fd..337de4be7d 100644 --- a/src/modules/icolib/IcoLib.h +++ b/src/modules/icolib/IcoLib.h @@ -98,7 +98,7 @@ HICON IconItem_GetIcon(IcolibItem* item, bool big); int SkinOptionsInit(WPARAM, LPARAM);
-extern CRITICAL_SECTION csIconList;
+extern mir_cs csIconList;
extern LIST<IcolibItem> iconList;
extern LIST<SectionItem> sectionList;
diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp index 139a369eb2..35e77a8e37 100644 --- a/src/modules/icolib/skin2icons.cpp +++ b/src/modules/icolib/skin2icons.cpp @@ -39,7 +39,7 @@ int iconEventActive = 0; BOOL bNeedRebuild = FALSE;
-CRITICAL_SECTION csIconList;
+mir_cs csIconList;
static int sttCompareSections(const SectionItem* p1, const SectionItem* p2)
{
@@ -837,7 +837,6 @@ int LoadIcoLibModule(void) hIconBlank = LoadIconEx(NULL, MAKEINTRESOURCE(IDI_BLANK), 0);
- InitializeCriticalSection(&csIconList);
hIcoLib_AddNewIcon = CreateServiceFunction("Skin2/Icons/AddIcon", sttIcoLib_AddNewIcon);
hIcoLib_RemoveIcon = CreateServiceFunction(MS_SKIN2_REMOVEICON, IcoLib_RemoveIcon);
hIcoLib_GetIcon = CreateServiceFunction(MS_SKIN2_GETICON, sttIcoLib_GetIcon);
@@ -873,7 +872,6 @@ void UnloadIcoLibModule(void) DestroyServiceFunction(hIcoLib_IsManaged);
DestroyServiceFunction(hIcoLib_AddRef);
DestroyServiceFunction(hIcoLib_ReleaseIcon);
- DeleteCriticalSection(&csIconList);
for (i = iconList.getCount()-1; i >= 0; i--) {
IcolibItem* p = iconList[i];
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index 47e3b13763..64c42a575a 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -40,7 +40,7 @@ static int CompareNetlibUser(const NetlibUser* p1, const NetlibUser* p2) }
LIST<NetlibUser> netlibUser(5, CompareNetlibUser);
-CRITICAL_SECTION csNetlibUser;
+mir_cs csNetlibUser;
SSL_API si;
@@ -426,7 +426,6 @@ void UnloadNetlibModule(void) CloseHandle(hConnectionHeaderMutex);
if (hConnectionOpenMutex)
CloseHandle(hConnectionOpenMutex);
- DeleteCriticalSection(&csNetlibUser);
WSACleanup();
}
@@ -440,7 +439,6 @@ int LoadNetlibModule(void) HookEvent(ME_OPT_INITIALISE, NetlibOptInitialise);
- InitializeCriticalSection(&csNetlibUser);
hConnectionHeaderMutex = CreateMutex(NULL, FALSE, NULL);
NetlibLogInit();
diff --git a/src/modules/netlib/netlib.h b/src/modules/netlib/netlib.h index fa887e91a3..1312b5208a 100644 --- a/src/modules/netlib/netlib.h +++ b/src/modules/netlib/netlib.h @@ -120,7 +120,7 @@ INT_PTR NetlibBase64Encode(WPARAM wParam, LPARAM lParam); INT_PTR NetlibBase64Decode(WPARAM wParam, LPARAM lParam);
INT_PTR NetlibHttpUrlEncode(WPARAM wParam, LPARAM lParam);
-extern CRITICAL_SECTION csNetlibUser;
+extern mir_cs csNetlibUser;
extern LIST<NetlibUser> netlibUser;
//netlibautoproxy.c
diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp index ba0269065c..07b96903e6 100644 --- a/src/modules/netlib/netlibopenconn.cpp +++ b/src/modules/netlib/netlibopenconn.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
#include "netlib.h"
-extern CRITICAL_SECTION csNetlibUser;
+extern mir_cs csNetlibUser;
extern HANDLE hConnectionOpenMutex;
extern DWORD g_LastConnectionTick;
extern int connectionTimeout;
|