1 /*------------------------------------------------------------------------
2 Junction: Concurrent data structures in C++
3 Copyright (c) 2016-2017 Jeff Preshing
5 Distributed under the Simplified BSD License.
6 Original location: https://github.com/preshing/junction
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the LICENSE file for more information.
11 ------------------------------------------------------------------------*/
13 #include <junction/Core.h>
14 #include <junction/striped/ConditionBank.h>
16 #if JUNCTION_USE_STRIPING
21 ConditionBank DefaultConditionBank;
23 ConditionBank::~ConditionBank() {
24 m_initSpinLock.lock();
25 ConditionPair* pairs = m_pairs.exchange(nullptr, turf::ConsumeRelease);
27 m_initSpinLock.unlock();
30 ConditionPair* ConditionBank::initialize() {
31 m_initSpinLock.lock();
32 ConditionPair* pairs = m_pairs.loadNonatomic();
34 pairs = new ConditionPair[SizeMask + 1];
35 m_pairs.store(pairs, turf::Release);
37 m_initSpinLock.unlock();
41 } // namespace striped
42 } // namespace junction
44 #endif // JUNCTION_USE_STRIPING