diff options
-rw-r--r-- | base/resource_pool.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/base/resource_pool.hpp b/base/resource_pool.hpp index ceabe32bef..70df704d0f 100644 --- a/base/resource_pool.hpp +++ b/base/resource_pool.hpp @@ -194,8 +194,18 @@ struct AllocateOnDemandMultiThreadedPoolTraits : TBase elem_t const Reserve() { - base_t::m_pool.ProcessList(bind(&self_t::AllocateIfNeeded, this, _1)); - return base_t::Reserve(); + elem_t res; + base_t::m_pool.ProcessList(bind(&self_t::AllocateAndReserve, this, _1, ref(res))); + return res; + } + + void AllocateAndReserve(list<elem_t> & l, elem_t & res) + { + AllocateIfNeeded(l); + ASSERT ( !l.empty(), () ); + + res = l.front(); + l.pop_front(); } }; |