diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-05 16:13:24 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-05 16:32:10 -0500 |
commit | 4010884a5b898e79c32984a9355c37ad0a01a67b (patch) | |
tree | 10448987fc209d2deae101147a2d2413b9ba0e62 /libs/pbd/pool.cc | |
parent | 715263410430c5872677f193fdad869ff9a16567 (diff) |
expand PBD::Pool API and add additional DEBUG_TRACE output.
Expanded API splits apart some CrossThreadPool functionality, and provides
access to current pool status information (available(), total(), used(), pending_size())
Diffstat (limited to 'libs/pbd/pool.cc')
-rw-r--r-- | libs/pbd/pool.cc | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc index 234dfaeb18..b3e5c52e1a 100644 --- a/libs/pbd/pool.cc +++ b/libs/pbd/pool.cc @@ -222,16 +222,39 @@ CrossThreadPool::CrossThreadPool (string n, unsigned long isize, unsigned long } -void* -CrossThreadPool::alloc () +void +CrossThreadPool::flush_pending_with_ev (void *ptr) { - void* ptr; + push (ptr); + flush_pending (); +} - DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 has %3 pending free entries waiting\n", pthread_name(), name(), pending.read_space())); +void +CrossThreadPool::flush_pending () +{ + void* ptr; + bool did_release = false; + + DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 has %3 pending free entries waiting, status size %4 free %5 used %6\n", pthread_name(), name(), pending.read_space(), + total(), available(), used())); + while (pending.read (&ptr, 1) == 1) { DEBUG_TRACE (DEBUG::Pool, string_compose ("%1 %2 pushes back a pending free list entry before allocating\n", pthread_name(), name())); free_list.write (&ptr, 1); + did_release = true; + } + + if (did_release) { + DEBUG_TRACE (DEBUG::Pool, string_compose ("Pool size: %1 free %2 used %3 pending now %4\n", total(), available(), used(), pending_size())); } +} + +void* +CrossThreadPool::alloc () +{ + /* process anything waiting to be deleted (i.e. moved back to the free list) */ + flush_pending (); + /* now allocate from the potentially larger free list */ return Pool::alloc (); } |