diff options
Diffstat (limited to 'libs/pbd/pbd')
-rw-r--r-- | libs/pbd/pbd/abstract_ui.cc | 12 | ||||
-rw-r--r-- | libs/pbd/pbd/abstract_ui.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/command.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/controllable.h | 11 | ||||
-rw-r--r-- | libs/pbd/pbd/error.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/mathfix.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/memento_command.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/mountpoint.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/pool.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/rcu.h | 19 | ||||
-rw-r--r-- | libs/pbd/pbd/receiver.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/replace_all.h | 8 | ||||
-rw-r--r-- | libs/pbd/pbd/ringbuffer.h | 146 | ||||
-rw-r--r-- | libs/pbd/pbd/ringbufferNPT.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/selectable.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/stateful.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/stl_delete.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/stl_functors.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/strsplit.h | 2 | ||||
-rw-r--r-- | libs/pbd/pbd/textreceiver.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/thrown_error.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/touchable.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/transmitter.h | 1 | ||||
-rw-r--r-- | libs/pbd/pbd/undo.h | 1 |
24 files changed, 105 insertions, 111 deletions
diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index eca53916af..97f19e1fe5 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -54,6 +54,8 @@ AbstractUI<RequestObject>::get_request (RequestType rt) } RequestBufferVector vec; + vec.buf[0] = 0; + vec.buf[1] = 0; rbuf->get_write_vector (&vec); @@ -100,16 +102,10 @@ AbstractUI<RequestObject>::handle_ui_requests () if (vec.len[0] == 0) { break; } else { - /* request_factory/copy constructor does a deep - copy of the Request object, - unlike Ringbuffer::read() - */ - - RequestObject req (*vec.buf[0]); - i->second->increment_read_ptr (1); request_buffer_map_lock.unlock (); - do_request (&req); + do_request (vec.buf[0]); request_buffer_map_lock.lock (); + i->second->increment_read_ptr (1); } } } diff --git a/libs/pbd/pbd/abstract_ui.h b/libs/pbd/pbd/abstract_ui.h index f80db7bf1a..88c27aa0bc 100644 --- a/libs/pbd/pbd/abstract_ui.h +++ b/libs/pbd/pbd/abstract_ui.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __pbd_abstract_ui_h__ diff --git a/libs/pbd/pbd/command.h b/libs/pbd/pbd/command.h index 8044b51a83..23bcf85b91 100644 --- a/libs/pbd/pbd/command.h +++ b/libs/pbd/pbd/command.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: /local/undo/libs/pbd3/pbd/undo.h 80 2006-06-22T22:37:01.079855Z fugalh $ */ #ifndef __lib_pbd_command_h__ diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h index c88eb298bc..c152013c66 100644 --- a/libs/pbd/pbd/controllable.h +++ b/libs/pbd/pbd/controllable.h @@ -2,6 +2,7 @@ #define __pbd_controllable_h__ #include <string> +#include <set> #include <sigc++/trackable.h> #include <sigc++/signal.h> @@ -36,8 +37,18 @@ class Controllable : public PBD::StatefulDestructible { std::string name() const { return _name; } + static Controllable* by_id (const PBD::ID&); + static Controllable* by_name (const std::string&); + private: std::string _name; + + void add (); + void remove (); + + typedef std::set<PBD::Controllable*> Controllables; + static Glib::Mutex* registry_lock; + static Controllables registry; }; } diff --git a/libs/pbd/pbd/error.h b/libs/pbd/pbd/error.h index 4136f02ee2..58842d68eb 100644 --- a/libs/pbd/pbd/error.h +++ b/libs/pbd/pbd/error.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __libpbd_error_h__ #define __libpbd_error_h__ diff --git a/libs/pbd/pbd/mathfix.h b/libs/pbd/pbd/mathfix.h index f0dc7e491e..fd0468905f 100644 --- a/libs/pbd/pbd/mathfix.h +++ b/libs/pbd/pbd/mathfix.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __pbd_mathfix_h__ diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index fe1aa8e7d0..d913b2c0fe 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: /local/undo/libs/pbd3/pbd/undo.h 132 2006-06-29T18:45:16.609763Z fugalh $ */ #ifndef __lib_pbd_memento_command_h__ diff --git a/libs/pbd/pbd/mountpoint.h b/libs/pbd/pbd/mountpoint.h index 86ccc58190..e0ec1be7f9 100644 --- a/libs/pbd/pbd/mountpoint.h +++ b/libs/pbd/pbd/mountpoint.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __pbd_mountpoint_h__ diff --git a/libs/pbd/pbd/pool.h b/libs/pbd/pbd/pool.h index f8e19e72fb..d604680ae2 100644 --- a/libs/pbd/pbd/pool.h +++ b/libs/pbd/pbd/pool.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __qm_pool_h__ diff --git a/libs/pbd/pbd/rcu.h b/libs/pbd/pbd/rcu.h index a8f3cdd5bc..8b0b8b3548 100644 --- a/libs/pbd/pbd/rcu.h +++ b/libs/pbd/pbd/rcu.h @@ -12,22 +12,21 @@ class RCUManager public: RCUManager (T* new_rcu_value) { - m_rcu_value = new boost::shared_ptr<T> (new_rcu_value); + x.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 (the_pointer())); } + boost::shared_ptr<T> reader () const { return *((boost::shared_ptr<T> *) g_atomic_pointer_get (&x.gptr)); } virtual boost::shared_ptr<T> write_copy () = 0; virtual bool update (boost::shared_ptr<T> new_value) = 0; protected: - boost::shared_ptr<T>* m_rcu_value; - - // this monstrosity is needed because of some wierd behavior by g++ - - gpointer * the_pointer() const { return (gpointer *) &m_rcu_value; } + union { + boost::shared_ptr<T>* m_rcu_value; + mutable volatile gpointer gptr; + } x; }; @@ -60,7 +59,7 @@ public: // store the current - current_write_old = RCUManager<T>::m_rcu_value; + current_write_old = RCUManager<T>::x.m_rcu_value; boost::shared_ptr<T> new_copy (new T(**current_write_old)); @@ -76,7 +75,7 @@ public: // update, checking that nobody beat us to it - bool ret = g_atomic_pointer_compare_and_exchange (RCUManager<T>::the_pointer(), + bool ret = g_atomic_pointer_compare_and_exchange (&RCUManager<T>::x.gptr, (gpointer) current_write_old, (gpointer) new_spp); diff --git a/libs/pbd/pbd/receiver.h b/libs/pbd/pbd/receiver.h index 5ce238df63..93192ce787 100644 --- a/libs/pbd/pbd/receiver.h +++ b/libs/pbd/pbd/receiver.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __libmisc_receiver_h__ diff --git a/libs/pbd/pbd/replace_all.h b/libs/pbd/pbd/replace_all.h new file mode 100644 index 0000000000..4434637283 --- /dev/null +++ b/libs/pbd/pbd/replace_all.h @@ -0,0 +1,8 @@ +#ifndef __pbd_replace_all_h__ +#define __pbd_replace_all_h__ + +#include <string> + +int replace_all (std::string& str, const std::string& target, const std::string& replacement); + +#endif // __pbd_replace_all_h__ diff --git a/libs/pbd/pbd/ringbuffer.h b/libs/pbd/pbd/ringbuffer.h index 1d9c9b04e3..d98601461e 100644 --- a/libs/pbd/pbd/ringbuffer.h +++ b/libs/pbd/pbd/ringbuffer.h @@ -15,25 +15,21 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef ringbuffer_h #define ringbuffer_h -//#include <sys/mman.h> - #include <glib.h> template<class T> class RingBuffer { public: - RingBuffer (size_t sz) { - size_t power_of_two; - - for (power_of_two = 1; 1U<<power_of_two < sz; power_of_two++); - + RingBuffer (guint sz) { +// size = ffs(sz); /* find first [bit] set is a single inlined assembly instruction. But it looks like the API rounds up so... */ + guint power_of_two; + for (power_of_two = 1; 1U<<power_of_two < sz; power_of_two++); size = 1<<power_of_two; size_mask = size; size_mask -= 1; @@ -48,44 +44,44 @@ class RingBuffer void reset () { /* !!! NOT THREAD SAFE !!! */ - g_atomic_int_set (&write_ptr, 0); - g_atomic_int_set (&read_ptr, 0); + g_atomic_int_set (&write_idx, 0); + g_atomic_int_set (&read_idx, 0); } - void set (size_t r, size_t w) { + void set (guint r, guint w) { /* !!! NOT THREAD SAFE !!! */ - g_atomic_int_set (&write_ptr, w); - g_atomic_int_set (&read_ptr, r); + g_atomic_int_set (&write_idx, w); + g_atomic_int_set (&read_idx, r); } - size_t read (T *dest, size_t cnt); - size_t write (T *src, size_t cnt); + guint read (T *dest, guint cnt); + guint write (T *src, guint cnt); struct rw_vector { T *buf[2]; - size_t len[2]; + guint len[2]; }; void get_read_vector (rw_vector *); void get_write_vector (rw_vector *); - void decrement_read_ptr (size_t cnt) { - g_atomic_int_set (&read_ptr, (g_atomic_int_get(&read_ptr) - cnt) & size_mask); + void decrement_read_idx (guint cnt) { + g_atomic_int_set (&read_idx, (g_atomic_int_get(&read_idx) - cnt) & size_mask); } - void increment_read_ptr (size_t cnt) { - g_atomic_int_set (&read_ptr, (g_atomic_int_get(&read_ptr) + cnt) & size_mask); + void increment_read_idx (guint cnt) { + g_atomic_int_set (&read_idx, (g_atomic_int_get(&read_idx) + cnt) & size_mask); } - void increment_write_ptr (size_t cnt) { - g_atomic_int_set (&write_ptr, (g_atomic_int_get(&write_ptr) + cnt) & size_mask); + void increment_write_idx (guint cnt) { + g_atomic_int_set (&write_idx, (g_atomic_int_get(&write_idx) + cnt) & size_mask); } - size_t write_space () { - size_t w, r; + guint write_space () { + guint w, r; - w = g_atomic_int_get (&write_ptr); - r = g_atomic_int_get (&read_ptr); + w = g_atomic_int_get (&write_idx); + r = g_atomic_int_get (&read_idx); if (w > r) { return ((r - w + size) & size_mask) - 1; @@ -96,11 +92,11 @@ class RingBuffer } } - size_t read_space () { - size_t w, r; + guint read_space () { + guint w, r; - w = g_atomic_int_get (&write_ptr); - r = g_atomic_int_get (&read_ptr); + w = g_atomic_int_get (&write_idx); + r = g_atomic_int_get (&read_idx); if (w > r) { return w - r; @@ -110,28 +106,28 @@ class RingBuffer } T *buffer () { return buf; } - size_t get_write_ptr () const { return g_atomic_int_get (&write_ptr); } - size_t get_read_ptr () const { return g_atomic_int_get (&read_ptr); } - size_t bufsize () const { return size; } + guint get_write_idx () const { return g_atomic_int_get (&write_idx); } + guint get_read_idx () const { return g_atomic_int_get (&read_idx); } + guint bufsize () const { return size; } protected: T *buf; - size_t size; - mutable gint write_ptr; - mutable gint read_ptr; - size_t size_mask; + guint size; + mutable gint write_idx; + mutable gint read_idx; + guint size_mask; }; -template<class T> size_t -RingBuffer<T>::read (T *dest, size_t cnt) +template<class T> guint +RingBuffer<T>::read (T *dest, guint cnt) { - size_t free_cnt; - size_t cnt2; - size_t to_read; - size_t n1, n2; - size_t priv_read_ptr; + guint free_cnt; + guint cnt2; + guint to_read; + guint n1, n2; + guint priv_read_idx; - priv_read_ptr=g_atomic_int_get(&read_ptr); + priv_read_idx=g_atomic_int_get(&read_idx); if ((free_cnt = read_space ()) == 0) { return 0; @@ -139,39 +135,39 @@ RingBuffer<T>::read (T *dest, size_t cnt) to_read = cnt > free_cnt ? free_cnt : cnt; - cnt2 = priv_read_ptr + to_read; + cnt2 = priv_read_idx + to_read; if (cnt2 > size) { - n1 = size - priv_read_ptr; + n1 = size - priv_read_idx; n2 = cnt2 & size_mask; } else { n1 = to_read; n2 = 0; } - memcpy (dest, &buf[priv_read_ptr], n1 * sizeof (T)); - priv_read_ptr = (priv_read_ptr + n1) & size_mask; + memcpy (dest, &buf[priv_read_idx], n1 * sizeof (T)); + priv_read_idx = (priv_read_idx + n1) & size_mask; if (n2) { memcpy (dest+n1, buf, n2 * sizeof (T)); - priv_read_ptr = n2; + priv_read_idx = n2; } - g_atomic_int_set(&read_ptr, priv_read_ptr); + g_atomic_int_set(&read_idx, priv_read_idx); return to_read; } -template<class T> size_t -RingBuffer<T>::write (T *src, size_t cnt) +template<class T> guint +RingBuffer<T>::write (T *src, guint cnt) { - size_t free_cnt; - size_t cnt2; - size_t to_write; - size_t n1, n2; - size_t priv_write_ptr; + guint free_cnt; + guint cnt2; + guint to_write; + guint n1, n2; + guint priv_write_idx; - priv_write_ptr=g_atomic_int_get(&write_ptr); + priv_write_idx=g_atomic_int_get(&write_idx); if ((free_cnt = write_space ()) == 0) { return 0; @@ -179,25 +175,25 @@ RingBuffer<T>::write (T *src, size_t cnt) to_write = cnt > free_cnt ? free_cnt : cnt; - cnt2 = priv_write_ptr + to_write; + cnt2 = priv_write_idx + to_write; if (cnt2 > size) { - n1 = size - priv_write_ptr; + n1 = size - priv_write_idx; n2 = cnt2 & size_mask; } else { n1 = to_write; n2 = 0; } - memcpy (&buf[priv_write_ptr], src, n1 * sizeof (T)); - priv_write_ptr = (priv_write_ptr + n1) & size_mask; + memcpy (&buf[priv_write_idx], src, n1 * sizeof (T)); + priv_write_idx = (priv_write_idx + n1) & size_mask; if (n2) { memcpy (buf, src+n1, n2 * sizeof (T)); - priv_write_ptr = n2; + priv_write_idx = n2; } - g_atomic_int_set(&write_ptr, priv_write_ptr); + g_atomic_int_set(&write_idx, priv_write_idx); return to_write; } @@ -205,12 +201,12 @@ template<class T> void RingBuffer<T>::get_read_vector (RingBuffer<T>::rw_vector *vec) { - size_t free_cnt; - size_t cnt2; - size_t w, r; + guint free_cnt; + guint cnt2; + guint w, r; - w = g_atomic_int_get (&write_ptr); - r = g_atomic_int_get (&read_ptr); + w = g_atomic_int_get (&write_idx); + r = g_atomic_int_get (&read_idx); if (w > r) { free_cnt = w - r; @@ -245,12 +241,12 @@ template<class T> void RingBuffer<T>::get_write_vector (RingBuffer<T>::rw_vector *vec) { - size_t free_cnt; - size_t cnt2; - size_t w, r; + guint free_cnt; + guint cnt2; + guint w, r; - w = g_atomic_int_get (&write_ptr); - r = g_atomic_int_get (&read_ptr); + w = g_atomic_int_get (&write_idx); + r = g_atomic_int_get (&read_idx); if (w > r) { free_cnt = ((r - w + size) & size_mask) - 1; diff --git a/libs/pbd/pbd/ringbufferNPT.h b/libs/pbd/pbd/ringbufferNPT.h index fee2efce3d..9db09098d6 100644 --- a/libs/pbd/pbd/ringbufferNPT.h +++ b/libs/pbd/pbd/ringbufferNPT.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef ringbuffer_npt_h diff --git a/libs/pbd/pbd/selectable.h b/libs/pbd/pbd/selectable.h index 470bc3cfcc..85f3e79ab0 100644 --- a/libs/pbd/pbd/selectable.h +++ b/libs/pbd/pbd/selectable.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __selectable_h__ diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h index 5fbac11e5c..550db5a24e 100644 --- a/libs/pbd/pbd/stateful.h +++ b/libs/pbd/pbd/stateful.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: stateful.h 17 2005-09-24 19:13:41Z taybin $ */ #ifndef __pbd_stateful_h__ diff --git a/libs/pbd/pbd/stl_delete.h b/libs/pbd/pbd/stl_delete.h index 6e5bfa0734..66fb027387 100644 --- a/libs/pbd/pbd/stl_delete.h +++ b/libs/pbd/pbd/stl_delete.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __libmisc_stl_delete_h__ diff --git a/libs/pbd/pbd/stl_functors.h b/libs/pbd/pbd/stl_functors.h index 4a96e91a28..3c83a1ae2f 100644 --- a/libs/pbd/pbd/stl_functors.h +++ b/libs/pbd/pbd/stl_functors.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __stl_functors_h__ diff --git a/libs/pbd/pbd/strsplit.h b/libs/pbd/pbd/strsplit.h index e55ad1c825..f36a3ae5f0 100644 --- a/libs/pbd/pbd/strsplit.h +++ b/libs/pbd/pbd/strsplit.h @@ -3,7 +3,9 @@ #include <string> #include <vector> +#include <glibmm/ustring.h> extern void split (std::string, std::vector<std::string>&, char); +extern void split (Glib::ustring, std::vector<Glib::ustring>&, char); #endif // __pbd_strplit_h__ diff --git a/libs/pbd/pbd/textreceiver.h b/libs/pbd/pbd/textreceiver.h index b8bfe5bc78..e5900fc652 100644 --- a/libs/pbd/pbd/textreceiver.h +++ b/libs/pbd/pbd/textreceiver.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __libmisc_textreceiver_h__ diff --git a/libs/pbd/pbd/thrown_error.h b/libs/pbd/pbd/thrown_error.h index 83cf8acfac..0a63085f11 100644 --- a/libs/pbd/pbd/thrown_error.h +++ b/libs/pbd/pbd/thrown_error.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __qm_thrown_error_h__ #define __qm_thrown_error_h__ diff --git a/libs/pbd/pbd/touchable.h b/libs/pbd/pbd/touchable.h index 0298574dfa..12f1c443fd 100644 --- a/libs/pbd/pbd/touchable.h +++ b/libs/pbd/pbd/touchable.h @@ -14,7 +14,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __pbd_touchable_h__ diff --git a/libs/pbd/pbd/transmitter.h b/libs/pbd/pbd/transmitter.h index 357cb9965f..61ac9bd8d8 100644 --- a/libs/pbd/pbd/transmitter.h +++ b/libs/pbd/pbd/transmitter.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __libmisc_transmitter_h__ diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 4dfab5178f..9539d8b41d 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __lib_pbd_undo_h__ |