Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2013-01-13 01:26:42 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:48:38 +0300
commit7e8b40e59dff574713950219c039df19f01900b7 (patch)
treede2cb3fbe77f140862f4f1e8a7ca251e0b55d1c6 /base
parentd3d1741fecbd41afd7c44b237c564ce6356f2bbe (diff)
fixed deadlock when some thread steal newly allocated resource from the thread which allocates it.
Diffstat (limited to 'base')
-rw-r--r--base/resource_pool.hpp14
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();
}
};