diff options
author | David Robillard <d@drobilla.net> | 2009-11-01 17:25:38 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-11-01 17:25:38 +0000 |
commit | b63a9fd4ca4814a3eb642b6dceef0e507e1cdee3 (patch) | |
tree | ec55cf1d629141f4388451fc8c194e494bff4fe9 /libs | |
parent | 6bb54878523e4a9cbf9aa886758fa584d1a9bd0a (diff) |
Use shared_ptr::unique() instead of shared_ptr::use_count() == 1.
use_count() can be slow (not constant time) depending on underlying implementation.
Similar situation to std::list::size() == 0 an std::list::empty(), the former
does a big traversal/computation only to check if the very first step went.
I think the current boost implementation is just a reference count anyway, but
hey. In theory.
git-svn-id: svn://localhost/ardour2/branches/3.0@5996 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/pbd/pbd/rcu.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/pbd/pbd/rcu.h b/libs/pbd/pbd/rcu.h index 7c63acdb0d..82ba5ff325 100644 --- a/libs/pbd/pbd/rcu.h +++ b/libs/pbd/pbd/rcu.h @@ -96,7 +96,7 @@ class RCUManager The class maintains a lock-protected "dead wood" list of old value of *m_rcu_value (i.e. shared_ptr<T>). The list is cleaned up every time we call write_copy(). If the list is the last instance of a shared_ptr<T> that - references the object (determined by inspecting its use_count()) then we + references the object (determined by shared_ptr::unique()) then we erase it from the list, thus deleting the object it points to. This is lazy destruction - the SerializedRCUManager assumes that there will sufficient calls to write_copy() to ensure that we do not inadvertently leave objects @@ -127,7 +127,7 @@ public: typename std::list<boost::shared_ptr<T> >::iterator i; for (i = m_dead_wood.begin(); i != m_dead_wood.end(); ) { - if ((*i).use_count() == 1) { + if ((*i).unique()) { i = m_dead_wood.erase (i); } else { ++i; @@ -222,7 +222,7 @@ public: } ~RCUWriter() { - if (m_copy.use_count() == 1) { + if (m_copy.unique()) { /* As intended, our copy is the only reference to the object pointed to by m_copy. Update the manager with the (presumed) modified |