forked from organicmaps/organicmaps
fixed deadlock when some thread steal newly allocated resource from the thread which allocates it.
This commit is contained in:
parent
d3d1741fec
commit
7e8b40e59d
1 changed files with 12 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue