AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PowerMonitor.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_POWER_POWERMONITOR_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_POWER_POWERMONITOR_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <thread>
23 #include <unordered_map>
24 
27 
28 namespace alexaClientSDK {
29 namespace avsCommon {
30 namespace utils {
31 namespace power {
32 
41 class PowerMonitor {
42 public:
48  static std::shared_ptr<PowerMonitor> getInstance();
49 
55  void activate(std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> powerManager);
56 
62  bool isActive();
63 
70  void deactivate();
71 
77  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> getPowerResourceManager();
78 
89  std::shared_ptr<PowerResource> getThreadPowerResourceOrCreate(
90  const std::string& identifier,
93 
99  std::shared_ptr<PowerResource> getThreadPowerResource();
100 
108  std::shared_ptr<PowerResource> assignThreadPowerResource(std::shared_ptr<PowerResource> powerResource);
109 
118  std::shared_ptr<PowerResource> createLocalPowerResource(
119  const std::string& identifier,
122 
127 
128 private:
134  bool isActiveLocked();
135 
137  static std::mutex m_mutex;
138 
140  static std::shared_ptr<PowerMonitor> m_monitor;
141 
143  std::shared_ptr<sdkInterfaces::PowerResourceManagerInterface> m_powerManager;
144 
146  std::unordered_map<std::thread::id, std::shared_ptr<PowerResource>> m_threadPowerResources;
147 };
148 
149 } // namespace power
150 } // namespace utils
151 } // namespace avsCommon
152 } // namespace alexaClientSDK
153 
154 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_POWER_POWERMONITOR_H_
STANDBY_MED usually means all the hardware components work in the medium standby power levels...
PowerResourceLevel
Definition: PowerResourceManagerInterface.h:49
void activate(std::shared_ptr< sdkInterfaces::PowerResourceManagerInterface > powerManager)
::std::string string
Definition: gtest-port.h:1097
std::shared_ptr< PowerResource > createLocalPowerResource(const std::string &identifier, sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel level=sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED)
std::shared_ptr< PowerResource > getThreadPowerResource()
static std::shared_ptr< PowerMonitor > getInstance()
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::shared_ptr< PowerResource > assignThreadPowerResource(std::shared_ptr< PowerResource > powerResource)
std::shared_ptr< sdkInterfaces::PowerResourceManagerInterface > getPowerResourceManager()
std::shared_ptr< PowerResource > getThreadPowerResourceOrCreate(const std::string &identifier, sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel level=sdkInterfaces::PowerResourceManagerInterface::PowerResourceLevel::STANDBY_MED)

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0