From 2ba515370864b85bd29b0d23083248c74a868691 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 27 Mar 2022 19:30:30 +0200 Subject: Replaced own ThreadSync with atomic variable in Text --- FoundationEx/Text.cpp | 6 ------ FoundationEx/Text.h | 5 ++--- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'FoundationEx') 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 #include #include #include -#include "ThreadSync.h" // +-------------------------------------------------------------------+ @@ -42,12 +42,11 @@ private: void dohash(); char* data; - long ref; + std::atomic ref; int length; unsigned hash; bool sensitive; - static ThreadSync sync; static TextRep nullrep; }; -- cgit v1.1