summaryrefslogtreecommitdiff
path: root/libs/pbd/pool.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-04-29 22:55:27 +0000
committerCarl Hetherington <carl@carlh.net>2010-04-29 22:55:27 +0000
commitd57a472c16c9bd170e579dded005d621ae22407f (patch)
treeec84d51f9e667a5a881bc7575fbfc8e2e0069170 /libs/pbd/pool.cc
parent09f856c1a10fe01efc7b04b76a6d819e97e4e623 (diff)
Delete cross-thread pools when the thread terminates if they are empty. Hopefully fixes #3094.
git-svn-id: svn://localhost/ardour2/branches/3.0@7022 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/pool.cc')
-rw-r--r--libs/pbd/pool.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc
index abb8695c23..aac98a2c15 100644
--- a/libs/pbd/pool.cc
+++ b/libs/pbd/pool.cc
@@ -157,7 +157,18 @@ free_per_thread_pool (void* ptr)
CrossThreadPool* cp = static_cast<CrossThreadPool*> (ptr);
assert (cp);
- cp->parent()->add_to_trash (cp);
+ if (cp->empty()) {
+ /* This CrossThreadPool is already empty, and the thread is finishing so nothing
+ * more can be added to it. We can just delete the pool.
+ */
+ delete cp;
+ } else {
+ /* This CrossThreadPool is not empty, meaning that there's some Events in it
+ * which another thread may yet read, so we can't delete the pool just yet.
+ * Put it in the trash and hope someone deals with it at some stage.
+ */
+ cp->parent()->add_to_trash (cp);
+ }
}
PerThreadPool::PerThreadPool ()