drain.cc (11417:6e89c756e1fb) drain.cc (11859:76c36516e0ae)
1/*
2 * Copyright (c) 2012, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 25 unchanged lines hidden (view full) ---

34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Authors: Andreas Sandberg
38 */
39
40#include "sim/drain.hh"
41
1/*
2 * Copyright (c) 2012, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 25 unchanged lines hidden (view full) ---

34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Authors: Andreas Sandberg
38 */
39
40#include "sim/drain.hh"
41
42#include <algorithm>
43
42#include "base/misc.hh"
43#include "base/trace.hh"
44#include "debug/Drain.hh"
45#include "sim/sim_exit.hh"
46#include "sim/sim_object.hh"
47
48DrainManager DrainManager::_instance;
49

--- 71 unchanged lines hidden (view full) ---

121 _state = DrainState::Drained;
122 for (auto *obj : _allDrainable)
123 obj->_drainState = DrainState::Drained;
124}
125
126void
127DrainManager::signalDrainDone()
128{
44#include "base/misc.hh"
45#include "base/trace.hh"
46#include "debug/Drain.hh"
47#include "sim/sim_exit.hh"
48#include "sim/sim_object.hh"
49
50DrainManager DrainManager::_instance;
51

--- 71 unchanged lines hidden (view full) ---

123 _state = DrainState::Drained;
124 for (auto *obj : _allDrainable)
125 obj->_drainState = DrainState::Drained;
126}
127
128void
129DrainManager::signalDrainDone()
130{
131 assert(_count > 0);
129 if (--_count == 0) {
130 DPRINTF(Drain, "All %u objects drained..\n", drainableCount());
131 exitSimLoop("Finished drain", 0);
132 }
133}
134
135
136void
137DrainManager::registerDrainable(Drainable *obj)
138{
139 std::lock_guard<std::mutex> lock(globalLock);
132 if (--_count == 0) {
133 DPRINTF(Drain, "All %u objects drained..\n", drainableCount());
134 exitSimLoop("Finished drain", 0);
135 }
136}
137
138
139void
140DrainManager::registerDrainable(Drainable *obj)
141{
142 std::lock_guard<std::mutex> lock(globalLock);
140 _allDrainable.insert(obj);
143 assert(std::find(_allDrainable.begin(), _allDrainable.end(), obj) ==
144 _allDrainable.end());
145 _allDrainable.push_back(obj);
141}
142
143void
144DrainManager::unregisterDrainable(Drainable *obj)
145{
146 std::lock_guard<std::mutex> lock(globalLock);
146}
147
148void
149DrainManager::unregisterDrainable(Drainable *obj)
150{
151 std::lock_guard<std::mutex> lock(globalLock);
147 _allDrainable.erase(obj);
152 auto o = std::find(_allDrainable.begin(), _allDrainable.end(), obj);
153 assert(o != _allDrainable.end());
154 _allDrainable.erase(o);
148}
149
150size_t
151DrainManager::drainableCount() const
152{
153 std::lock_guard<std::mutex> lock(globalLock);
154 return _allDrainable.size();
155}

--- 35 unchanged lines hidden ---
155}
156
157size_t
158DrainManager::drainableCount() const
159{
160 std::lock_guard<std::mutex> lock(globalLock);
161 return _allDrainable.size();
162}

--- 35 unchanged lines hidden ---