mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Use std::atomic family
This commit is contained in:
committed by
Allan Odgaard
parent
aa24f237c6
commit
ca98e2f86d
@@ -23,24 +23,14 @@ namespace scope
|
||||
_parent->release();
|
||||
}
|
||||
|
||||
static std::mutex& retain_count_lock ()
|
||||
{
|
||||
static std::mutex* res = new std::mutex;
|
||||
return *res;
|
||||
}
|
||||
|
||||
void scope_t::node_t::retain ()
|
||||
{
|
||||
retain_count_lock().lock();
|
||||
++_retain_count;
|
||||
retain_count_lock().unlock();
|
||||
}
|
||||
|
||||
void scope_t::node_t::release ()
|
||||
{
|
||||
retain_count_lock().lock();
|
||||
bool shouldDelete = --_retain_count == 0;
|
||||
retain_count_lock().unlock();
|
||||
if(shouldDelete)
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace scope
|
||||
private:
|
||||
std::string _atoms;
|
||||
node_t* _parent;
|
||||
size_t _retain_count = 1;
|
||||
std::atomic_size_t _retain_count;
|
||||
};
|
||||
|
||||
explicit scope_t (node_t* node);
|
||||
|
||||
Reference in New Issue
Block a user