cross-thread handling of SessionEvent allocation/deallocation, with widespread conseq...
[ardour.git] / libs / pbd / pbd / pool.h
index 66a87abf96784ecd42f0b4256a9270ded931a09a..e8ad780dc2a6052a115d4dabc5f1569358a7638f 100644 (file)
@@ -38,9 +38,11 @@ class Pool
        
        std::string name() const { return _name; }
 
-  private:
-       RingBuffer<void*>* free_list;
+  protected:
+       RingBuffer<void*> free_list;
        std::string _name;
+
+  private:
        void *block;
 };
 
@@ -71,4 +73,33 @@ class MultiAllocSingleReleasePool : public Pool
     Glib::Mutex* m_lock;
 };
 
+class CrossThreadPool : public Pool
+{
+  public:
+       CrossThreadPool (std::string n, unsigned long isize, unsigned long nitems);
+
+       void* alloc ();
+       void push (void *);
+       
+  private:
+       RingBuffer<void*> pending;
+};
+
+class PerThreadPool
+{
+  public:
+       PerThreadPool ();
+
+       GPrivate* key() const { return _key; }
+
+       void  create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems);
+       CrossThreadPool* per_thread_pool ();
+       
+  private:
+       GPrivate* _key;
+       std::string _name;
+       unsigned long _item_size;
+       unsigned long _nitems;
+};
+
 #endif // __qm_pool_h__