From e3aa869ee712930f6d145d09029ecabcfbc9dd9f Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 24 Jul 2012 08:05:23 +0000 Subject: [PATCH] Core: DCL for INI fixes git-svn-id: svn://ultimatepp.org/upp/trunk@5232 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Ini.cpp | 32 ++++++++++++++------------------ uppsrc/Core/Util.h | 4 +--- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/uppsrc/Core/Ini.cpp b/uppsrc/Core/Ini.cpp index 7e23c5ca3..8f1d81f98 100644 --- a/uppsrc/Core/Ini.cpp +++ b/uppsrc/Core/Ini.cpp @@ -103,11 +103,13 @@ String GetIniKey(const char *id) return GetIniKey(id, String()); } -String IniString::Load() +static StaticMutex strMtx; + +IniString::operator String() { String x; { - Mutex::Lock __(sMtx); + Mutex::Lock __(strMtx); String& s = (*ref_fn)(); if(IniChanged__(version)) { s = TrimBoth(GetIniKey(id)); @@ -120,17 +122,9 @@ String IniString::Load() return x; } -IniString::operator String() -{ - String h = (*ref_fn)(); - if(IniChanged__(version)) - return Load(); - return h; -} - String IniString::operator=(const String& s) { - Mutex::Lock __(sMtx); + Mutex::Lock __(strMtx); (*ref_fn)() = s; IniSet__(version); return s; @@ -186,8 +180,10 @@ int IniInt::Load() { int IniInt::operator=(int b) { Mutex::Lock __(sMtx); + BarrierWrite(version, -1); + value = b; IniSet__(version); - return value = b; + return b; } String IniInt::ToString() const @@ -195,9 +191,11 @@ String IniInt::ToString() const return AsString((int)const_cast(*this)); } -int64 IniInt64::Load() +static StaticMutex si64Mtx; + +IniInt64::operator int64() { - Mutex::Lock __(sMtx); + Mutex::Lock __(si64Mtx); if(IniChanged__(version)) { value = ReadIniInt(id); if(IsNull(value)) @@ -209,11 +207,9 @@ int64 IniInt64::Load() int64 IniInt64::operator=(int64 b) { - Mutex::Lock __(sMtx); - BarrierWrite(version, -1); + Mutex::Lock __(si64Mtx); value = b; - IniSet__(version); - return value = b; + return b; } String IniInt64::ToString() const diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index 74ef85b66..9b09bd4c8 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -42,7 +42,6 @@ struct IniString { String (*def)(); String& (*ref_fn)(); int version; - String Load(); // "public:" operator String(); @@ -70,10 +69,9 @@ struct IniInt64 { int64 (*def)(); int version; int64 value; - int64 Load(); // "public:" - operator int64() { int64 h = value; if(IniChanged__(version)) return Load(); return h; } + operator int64(); int64 operator=(int64 b); String ToString() const; };