main.cpp (fe75b19359cde97397dc1548ea24ab90c4efa673) | main.cpp (5c7cc54577efc9fcb2ae4cb9f27e550f4f417694) |
---|---|
1/** 2 * Copyright 2017 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 8 unchanged lines hidden (view full) --- 17#include <chrono> 18#include <experimental/any> 19#include <getopt.h> 20#include <iostream> 21#include <map> 22#include <memory> 23#include <mutex> /* not yet used. */ 24#include <thread> | 1/** 2 * Copyright 2017 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 8 unchanged lines hidden (view full) --- 17#include <chrono> 18#include <experimental/any> 19#include <getopt.h> 20#include <iostream> 21#include <map> 22#include <memory> 23#include <mutex> /* not yet used. */ 24#include <thread> |
25#include <unordered_map> |
|
25#include <vector> 26 27#include <sdbusplus/bus.hpp> 28 29/* Configuration. */ 30#include "conf.hpp" 31 32/* Misc. */ 33#include "util.hpp" 34 35/* Controllers & Sensors. */ 36#include "interfaces.hpp" | 26#include <vector> 27 28#include <sdbusplus/bus.hpp> 29 30/* Configuration. */ 31#include "conf.hpp" 32 33/* Misc. */ 34#include "util.hpp" 35 36/* Controllers & Sensors. */ 37#include "interfaces.hpp" |
38#include "pid/builder.hpp" 39#include "pid/builderconfig.hpp" |
|
37#include "pid/zone.hpp" 38#include "sensors/builder.hpp" 39#include "sensors/builderconfig.hpp" 40#include "sensors/manager.hpp" 41 42/* Threads. */ 43#include "pid/pidthread.hpp" 44#include "threads/busthread.hpp" --- 36 unchanged lines hidden (view full) --- 81 default: 82 /* skip garbage. */ 83 continue; 84 } 85 } 86 87 auto ModeControlBus = sdbusplus::bus::new_default(); 88 SensorManager mgmr; | 40#include "pid/zone.hpp" 41#include "sensors/builder.hpp" 42#include "sensors/builderconfig.hpp" 43#include "sensors/manager.hpp" 44 45/* Threads. */ 46#include "pid/pidthread.hpp" 47#include "threads/busthread.hpp" --- 36 unchanged lines hidden (view full) --- 84 default: 85 /* skip garbage. */ 86 continue; 87 } 88 } 89 90 auto ModeControlBus = sdbusplus::bus::new_default(); 91 SensorManager mgmr; |
89 std::map<int64_t, std::shared_ptr<PIDZone>> zones; | 92 std::unordered_map<int64_t, std::unique_ptr<PIDZone>> zones; |
90 91 // Create a manager for the ModeBus because we own it. 92 static constexpr auto modeRoot = "/xyz/openbmc_project/settings/fanctrl"; 93 sdbusplus::server::manager::manager(ModeControlBus, modeRoot); 94 95 /* 96 * When building the sensors, if any of the dbus passive ones aren't on the 97 * bus, it'll fail immediately. --- 64 unchanged lines hidden (view full) --- 162 * it could have one thread for all the zones and iterate through each 163 * sequentially as it goes -- and it'd probably be fast enough to do that, 164 * however, a system isn't likely going to have more than a couple zones. 165 * If it only has a couple zones, then this is fine. 166 */ 167 for (auto& i : zones) 168 { 169 std::cerr << "pushing zone" << std::endl; | 93 94 // Create a manager for the ModeBus because we own it. 95 static constexpr auto modeRoot = "/xyz/openbmc_project/settings/fanctrl"; 96 sdbusplus::server::manager::manager(ModeControlBus, modeRoot); 97 98 /* 99 * When building the sensors, if any of the dbus passive ones aren't on the 100 * bus, it'll fail immediately. --- 64 unchanged lines hidden (view full) --- 165 * it could have one thread for all the zones and iterate through each 166 * sequentially as it goes -- and it'd probably be fast enough to do that, 167 * however, a system isn't likely going to have more than a couple zones. 168 * If it only has a couple zones, then this is fine. 169 */ 170 for (auto& i : zones) 171 { 172 std::cerr << "pushing zone" << std::endl; |
170 zoneThreads.push_back(std::thread(PIDControlThread, i.second)); | 173 zoneThreads.push_back(std::thread(PIDControlThread, i.second.get())); |
171 } 172 173 l.join(); 174 te.join(); 175 tm.join(); 176 for (auto& t : zoneThreads) 177 { 178 t.join(); 179 } 180 181 return rc; 182} 183 | 174 } 175 176 l.join(); 177 te.join(); 178 tm.join(); 179 for (auto& t : zoneThreads) 180 { 181 t.join(); 182 } 183 184 return rc; 185} 186 |