forked from organicmaps/organicmaps
[drape] more than one thread can read one tile
This commit is contained in:
parent
9fbb9f2019
commit
8bd37e34dc
2 changed files with 23 additions and 8 deletions
|
@ -73,6 +73,13 @@ namespace df
|
|||
|
||||
void BatchersPool::ReserveBatcher(TileKey const & key)
|
||||
{
|
||||
reserved_batchers_t::iterator it = m_reservedBatchers.find(key);
|
||||
if (it != m_reservedBatchers.end())
|
||||
{
|
||||
it->second.second++;
|
||||
return;
|
||||
}
|
||||
|
||||
MasterPointer<Batcher> reserved;
|
||||
if (m_batchers.empty())
|
||||
reserved.Reset(new Batcher());
|
||||
|
@ -83,7 +90,7 @@ namespace df
|
|||
}
|
||||
|
||||
reserved->StartSession(bind(&FlushGeometry, m_sendMessageFn, key, _1, _2));
|
||||
VERIFY(m_reservedBatchers.insert(make_pair(key, reserved)).second, ());
|
||||
VERIFY(m_reservedBatchers.insert(make_pair(key, make_pair(reserved, 1))).second, ());
|
||||
}
|
||||
|
||||
RefPointer<Batcher> BatchersPool::GetTileBatcher(TileKey const & key)
|
||||
|
@ -91,7 +98,7 @@ namespace df
|
|||
reserved_batchers_t::iterator it = m_reservedBatchers.find(key);
|
||||
|
||||
ASSERT(it != m_reservedBatchers.end(), ());
|
||||
return it->second.GetRefPointer();
|
||||
return it->second.first.GetRefPointer();
|
||||
}
|
||||
|
||||
void BatchersPool::ReleaseBatcher(TileKey const & key)
|
||||
|
@ -99,9 +106,12 @@ namespace df
|
|||
reserved_batchers_t::iterator it = m_reservedBatchers.find(key);
|
||||
|
||||
ASSERT(it != m_reservedBatchers.end(), ());
|
||||
MasterPointer<Batcher> batcher = it->second;
|
||||
batcher->EndSession();
|
||||
m_reservedBatchers.erase(it);
|
||||
m_batchers.push(batcher);
|
||||
if ((--it->second.second)== 0)
|
||||
{
|
||||
MasterPointer<Batcher> batcher = it->second.first;
|
||||
batcher->EndSession();
|
||||
m_reservedBatchers.erase(it);
|
||||
m_batchers.push(batcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ class Batcher;
|
|||
namespace df
|
||||
{
|
||||
class Message;
|
||||
// Not thread safe
|
||||
class BatchersPool
|
||||
{
|
||||
public:
|
||||
|
@ -29,8 +30,12 @@ namespace df
|
|||
void ReleaseBatcher(TileKey const & key);
|
||||
|
||||
private:
|
||||
stack<MasterPointer<Batcher> > m_batchers;
|
||||
typedef map<TileKey, MasterPointer<Batcher> > reserved_batchers_t;
|
||||
typedef MasterPointer<Batcher> batcher_ptr;
|
||||
typedef stack<batcher_ptr> batchers_pool_t;
|
||||
typedef pair<batcher_ptr, int> counted_batcher_t;
|
||||
typedef map<TileKey, counted_batcher_t> reserved_batchers_t;
|
||||
|
||||
batchers_pool_t m_batchers;
|
||||
reserved_batchers_t m_reservedBatchers;
|
||||
|
||||
send_message_fn m_sendMessageFn;
|
||||
|
|
Loading…
Add table
Reference in a new issue