diff options
author | Aki <please@ignore.pl> | 2022-03-27 19:30:30 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-03-27 19:30:30 +0200 |
commit | 2ba515370864b85bd29b0d23083248c74a868691 (patch) | |
tree | ed2252bb9ea2343f3b9932f5906e59ca828d24b7 /FoundationEx | |
parent | a12e588079700d55a0b788fea2df7727c2e41f52 (diff) | |
download | starshatter-2ba515370864b85bd29b0d23083248c74a868691.zip starshatter-2ba515370864b85bd29b0d23083248c74a868691.tar.gz starshatter-2ba515370864b85bd29b0d23083248c74a868691.tar.bz2 |
Replaced own ThreadSync with atomic variable in Text
Diffstat (limited to 'FoundationEx')
-rw-r--r-- | FoundationEx/Text.cpp | 6 | ||||
-rw-r--r-- | FoundationEx/Text.h | 5 |
2 files changed, 2 insertions, 9 deletions
diff --git a/FoundationEx/Text.cpp b/FoundationEx/Text.cpp index e73149a..972db7f 100644 --- a/FoundationEx/Text.cpp +++ b/FoundationEx/Text.cpp @@ -33,8 +33,6 @@ TextRep::TextRep() // +-------------------------------------------------------------------+ -ThreadSync TextRep::sync; - TextRep::TextRep(const char* s) : ref(1), length(0), sensitive(true) @@ -101,17 +99,13 @@ TextRep::~TextRep() void TextRep::addref() { - sync.acquire(); ref++; - sync.release(); } long TextRep::deref() { - sync.acquire(); long r = --ref; - sync.release(); return r; } diff --git a/FoundationEx/Text.h b/FoundationEx/Text.h index df5edae..0ade946 100644 --- a/FoundationEx/Text.h +++ b/FoundationEx/Text.h @@ -14,11 +14,11 @@ #ifndef Text_h #define Text_h +#include <atomic> #include <ostream> #include <string.h> #include <windows.h> -#include "ThreadSync.h" // +-------------------------------------------------------------------+ @@ -42,12 +42,11 @@ private: void dohash(); char* data; - long ref; + std::atomic<long> ref; int length; unsigned hash; bool sensitive; - static ThreadSync sync; static TextRep nullrep; }; |