summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-02-26 19:02:48 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-02-26 19:02:48 +0000
commit3f95dc7a08cfd81481ccb27c0d0b67c814e16779 (patch)
treefd8e4797963786e034b36580bfda922ce4427440 /libs/pbd
parent44a3f5419b5d51dc60c7024294fca4a7f2824491 (diff)
clean up RCU fix even more; nedko's missing sources patch
git-svn-id: svn://localhost/ardour2/trunk@1514 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/pbd/rcu.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/libs/pbd/pbd/rcu.h b/libs/pbd/pbd/rcu.h
index c9088d51df..86cc6e8cab 100644
--- a/libs/pbd/pbd/rcu.h
+++ b/libs/pbd/pbd/rcu.h
@@ -10,23 +10,21 @@ template<class T>
class RCUManager
{
public:
-
RCUManager (T* new_rcu_value) {
- x.m_rcu_value = new boost::shared_ptr<T> (new_rcu_value);
+ m_rcu_value = new boost::shared_ptr<T> (new_rcu_value);
}
+
+ virtual ~RCUManager() { delete m_rcu_value; }
- virtual ~RCUManager() { delete x.m_rcu_value; }
-
- boost::shared_ptr<T> reader () const { return *((boost::shared_ptr<T> *) g_atomic_pointer_get (&x.gptr)); }
+ boost::shared_ptr<T> reader () const { return *((boost::shared_ptr<T> *) g_atomic_pointer_get ((volatile gpointer*) &m_rcu_value)); }
virtual boost::shared_ptr<T> write_copy () = 0;
virtual bool update (boost::shared_ptr<T> new_value) = 0;
+ volatile gpointer* pointer() const { return (volatile gpointer*) &m_rcu_value; }
+
protected:
- union {
- boost::shared_ptr<T>* m_rcu_value;
- volatile gpointer gptr;
- } x;
+ volatile boost::shared_ptr<T>* m_rcu_value;
};
@@ -59,7 +57,7 @@ public:
// store the current
- current_write_old = RCUManager<T>::x.m_rcu_value;
+ current_write_old = (boost::shared_ptr<T>*) RCUManager<T>::m_rcu_value;
boost::shared_ptr<T> new_copy (new T(**current_write_old));
@@ -75,7 +73,7 @@ public:
// update, checking that nobody beat us to it
- bool ret = g_atomic_pointer_compare_and_exchange (&RCUManager<T>::x.gptr,
+ bool ret = g_atomic_pointer_compare_and_exchange (RCUManager<T>::pointer(),
(gpointer) current_write_old,
(gpointer) new_spp);