Commit 960f25fd authored by Andrey Kamakin's avatar Andrey Kamakin

Removed singleton from QSBR.

Ref T8874
parent 3623fc02
......@@ -26,6 +26,7 @@ public:
private:
Atomic<typename Details::Table*> m_root;
QSBR m_gc;
public:
ConcurrentMap(quint64 capacity = Details::InitialSize) : m_root(Details::Table::create(capacity))
......@@ -38,6 +39,11 @@ public:
table->destroy();
}
QSBR &getGC()
{
return m_gc;
}
// publishTableMigration() is called by exactly one thread from Details::TableMigration::run()
// after all the threads participating in the migration have completed their work.
void publishTableMigration(typename Details::TableMigration* migration)
......
......@@ -541,7 +541,7 @@ endMigration:
}
// We're done with this TableMigration. Queue it for GC.
QSBR::instance().enqueue(&TableMigration::destroy, this);
m_map.getGC().enqueue(&TableMigration::destroy, this);
}
#endif // LEAPFROG_H
......@@ -68,17 +68,11 @@ private:
}
}
QSBR() : m_freeIndex(-1), m_numContexts(0), m_remaining(0)
{
}
public:
typedef qint16 Context;
static QSBR &instance()
QSBR() : m_freeIndex(-1), m_numContexts(0), m_remaining(0)
{
static QSBR m_instance;
return m_instance;
}
Context createContext()
......
......@@ -33,7 +33,7 @@ public:
if (result) {
MemoryReclaimer *tmp = new MemoryReclaimer(result);
QSBR::instance().enqueue(&MemoryReclaimer::destroy, tmp);
m_map.getGC().enqueue(&MemoryReclaimer::destroy, tmp);
} else {
m_numTiles.fetchAndAddRelaxed(1);
}
......@@ -52,11 +52,11 @@ public:
if (result) {
m_numTiles.fetchAndSubRelaxed(1);
MemoryReclaimer *tmp = new MemoryReclaimer(result);
QSBR::instance().enqueue(&MemoryReclaimer::destroy, tmp);
m_map.getGC().enqueue(&MemoryReclaimer::destroy, tmp);
}
if (m_rawPointerUsers == 1) {
QSBR::instance().update(m_context);
m_map.getGC().update(m_context);
}
m_rawPointerUsers.fetchAndSubRelaxed(1);
......@@ -83,7 +83,7 @@ public:
if (result) {
MemoryReclaimer *tmp = new MemoryReclaimer(result);
QSBR::instance().enqueue(&MemoryReclaimer::destroy, tmp);
m_map.getGC().enqueue(&MemoryReclaimer::destroy, tmp);
} else {
newTile = true;
m_numTiles.fetchAndAddRelaxed(1);
......@@ -231,9 +231,10 @@ private:
template <class T>
KisTileHashTableTraits2<T>::KisTileHashTableTraits2()
: m_context(QSBR::instance().createContext()), m_rawPointerUsers(0), m_numTiles(0),
: m_rawPointerUsers(0), m_numTiles(0),
m_defaultTileData(0), m_mementoManager(0)
{
m_context = m_map.getGC().createContext();
}
template <class T>
......@@ -259,7 +260,7 @@ template <class T>
KisTileHashTableTraits2<T>::~KisTileHashTableTraits2()
{
clear();
QSBR::instance().destroyContext(m_context);
m_map.getGC().destroyContext(m_context);
}
template<class T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment