fixed deadlock when some thread steal newly allocated resource from the thread which allocates it.

This commit is contained in:
rachytski 2013-01-13 00:26:42 +03:00 committed by Alex Zolotarev
parent d3d1741fec
commit 7e8b40e59d

View file

@ -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();
}
};