Added a destructor to the ConditionBank class to deallocate the m_pair array.
Valgrind was used to test the shutdown of samples/MallocTest was clean.
Additional changes were needed in MallocTest to register with and update QSBR
so the table migration would be cleaned up.
/*------------------------------------------------------------------------
Junction: Concurrent data structures in C++
/*------------------------------------------------------------------------
Junction: Concurrent data structures in C++
- Copyright (c) 2016 Jeff Preshing
+ Copyright (c) 2016-2017 Jeff Preshing
Distributed under the Simplified BSD License.
Original location: https://github.com/preshing/junction
Distributed under the Simplified BSD License.
Original location: https://github.com/preshing/junction
ConditionBank DefaultConditionBank;
ConditionBank DefaultConditionBank;
+ConditionBank::~ConditionBank() {
+ m_initSpinLock.lock();
+ ConditionPair* pairs = m_pairs.exchange(nullptr, turf::ConsumeRelease);
+ delete [] pairs;
+ m_initSpinLock.unlock();
+}
+
ConditionPair* ConditionBank::initialize() {
m_initSpinLock.lock();
ConditionPair* pairs = m_pairs.loadNonatomic();
ConditionPair* ConditionBank::initialize() {
m_initSpinLock.lock();
ConditionPair* pairs = m_pairs.loadNonatomic();
/*------------------------------------------------------------------------
Junction: Concurrent data structures in C++
/*------------------------------------------------------------------------
Junction: Concurrent data structures in C++
- Copyright (c) 2016 Jeff Preshing
+ Copyright (c) 2016-2017 Jeff Preshing
Distributed under the Simplified BSD License.
Original location: https://github.com/preshing/junction
Distributed under the Simplified BSD License.
Original location: https://github.com/preshing/junction
ConditionPair* initialize();
public:
ConditionPair* initialize();
public:
ConditionPair& get(void* ptr) {
ConditionPair* pairs = m_pairs.load(turf::Consume);
if (!pairs) {
ConditionPair& get(void* ptr) {
ConditionPair* pairs = m_pairs.load(turf::Consume);
if (!pairs) {
/*------------------------------------------------------------------------
Junction: Concurrent data structures in C++
/*------------------------------------------------------------------------
Junction: Concurrent data structures in C++
- Copyright (c) 2016 Jeff Preshing
+ Copyright (c) 2016-2017 Jeff Preshing
Distributed under the Simplified BSD License.
Original location: https://github.com/preshing/junction
Distributed under the Simplified BSD License.
Original location: https://github.com/preshing/junction
junction::extra::MapAdapter::ThreadContext context(adapter, 0);
junction::extra::MapAdapter::Map map(65536);
junction::extra::MapAdapter::ThreadContext context(adapter, 0);
junction::extra::MapAdapter::Map map(65536);
+ context.registerThread();
+
ureg population = 0;
for (ureg i = 0; i < 100; i++) {
#if TURF_USE_DLMALLOC && TURF_DLMALLOC_FAST_STATS
ureg population = 0;
for (ureg i = 0; i < 100; i++) {
#if TURF_USE_DLMALLOC && TURF_DLMALLOC_FAST_STATS
map.assign(population + 1, (void*) ((population << 2) | 3));
}
map.assign(population + 1, (void*) ((population << 2) | 3));
}
+ context.update();
+ context.unregisterThread();
+