summaryrefslogtreecommitdiff
path: root/libs/ardour/session_events.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-12-04 19:24:09 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-12-04 19:24:09 +0000
commit4a3d7877f6b03fac7755f997b945583ba5732d13 (patch)
tree1099df5854224acbb17a650215d7f07710b8babe /libs/ardour/session_events.cc
parent478fd92039443743babec98812f10921209f1e5a (diff)
cross-thread handling of SessionEvent allocation/deallocation, with widespread consequences
git-svn-id: svn://localhost/ardour2/branches/3.0@6283 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_events.cc')
-rw-r--r--libs/ardour/session_events.cc40
1 files changed, 39 insertions, 1 deletions
diff --git a/libs/ardour/session_events.cc b/libs/ardour/session_events.cc
index 98620e269f..8818436ed7 100644
--- a/libs/ardour/session_events.cc
+++ b/libs/ardour/session_events.cc
@@ -37,7 +37,45 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
-MultiAllocSingleReleasePool SessionEvent::pool ("event", sizeof (SessionEvent), 512);
+PerThreadPool* SessionEvent::pool;
+
+void
+SessionEvent::init_event_pool ()
+{
+ pool = new PerThreadPool;
+}
+
+void
+SessionEvent::create_per_thread_pool (const std::string& name, unsigned long nitems)
+{
+ /* this is a per-thread call that simply creates a thread-private ptr to
+ a CrossThreadPool for use by this thread whenever events are allocated/released
+ from SessionEvent::pool()
+ */
+ pool->create_per_thread_pool (name, sizeof (SessionEvent), nitems);
+}
+
+void *
+SessionEvent::operator new (size_t)
+{
+ CrossThreadPool* p = pool->per_thread_pool ();
+ SessionEvent* ev = static_cast<SessionEvent*> (p->alloc ());
+ ev->own_pool = p;
+ return ev;
+}
+
+void
+SessionEvent::operator delete (void *ptr, size_t /*size*/)
+{
+ Pool* p = pool->per_thread_pool ();
+ SessionEvent* ev = static_cast<SessionEvent*> (ptr);
+
+ if (p == ev->own_pool) {
+ p->release (ptr);
+ } else {
+ ev->own_pool->push (ev);
+ }
+}
void
SessionEventManager::add_event (nframes64_t frame, SessionEvent::Type type, nframes64_t target_frame)