Commit 566804f2 authored by Andrey Kamakin's avatar Andrey Kamakin

Fixed map test and erase method.

Ref T8874
parent 76c0abb5
......@@ -205,7 +205,7 @@ public:
if (m_cell->value.compareExchangeStrong(m_value, Value(ValueTraits::NullValue), Consume)) {
// Exchange was successful and a non-NULL value was erased and returned by reference in m_value.
// Q_ASSERT(m_value != ValueTraits::NullValue); // Implied by the test at the start of the loop.
Q_ASSERT(m_value != Value(ValueTraits::NullValue)); // Implied by the test at the start of the loop.
Value result = m_value;
m_value = Value(ValueTraits::NullValue); // Leave the mutator in a valid state
return result;
......
......@@ -43,6 +43,7 @@ public:
qint32 currentThreads = m_rawPointerUsers.fetchAdd(1, ConsumeRelease);
TileType *result = m_map.erase(key);
TileTypeSP ptr(result);
if (result) {
MemoryReclaimer *tmp = new MemoryReclaimer(result);
QSBR::instance().enqueue(&MemoryReclaimer::destroy, tmp);
......@@ -54,7 +55,7 @@ public:
}
m_rawPointerUsers.fetchSub(1, ConsumeRelease);
return TileTypeSP(result);
return ptr;
}
TileTypeSP get(qint32 key)
......
......@@ -15,6 +15,7 @@
class Wrapper : public KisShared
{
public:
Wrapper() {}
Wrapper(qint32 member) : m_member(member) {}
qint32 member()
......@@ -78,7 +79,6 @@ private:
KisTileHashTableTraits2<Wrapper> &m_map;
qint64 m_eraseSum;
qint64 m_insertSum;
qint64 m_getSum;
};
void LockFreeMapTest::testWrapper()
......@@ -107,7 +107,7 @@ void LockFreeMapTest::testWrapper()
qint64 insertSum = 0;
qint64 eraseSum = 0;
for (auto i = 0; i < NUM_THREADS; i++) {
for (qint32 i = 0; i < NUM_THREADS; ++i) {
StressJobWrapper *job = jobs.takeLast();
eraseSum += job->eraseSum();
insertSum += job->insertSum();
......
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