universal7885: fm-aidl: Use std::timed_mutex to provide thread safe operation

- Also sort out common macro to new header
This commit is contained in:
roynatech2544 2022-10-17 18:59:42 +09:00
commit 30f8177b3d
6 changed files with 49 additions and 13 deletions

View file

@ -16,6 +16,8 @@
#include <chrono>
#include <thread>
#include <FileIO.h>
#include "BatteryConstants.h"
namespace aidl::vendor::eureka::hardware::parts {
@ -25,7 +27,7 @@ static int restart = 0;
static int limit_stat = 0;
static int restart_stat = 0;
static std::thread monitor_th = nullptr;
static std::thread *monitor_th = nullptr;
static void battery_monitor(void) {
while (true) {
@ -46,7 +48,7 @@ static void battery_monitor(void) {
return ::ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "Start called without configuring.");
monitor_th = std::thread(battery_monitor);
monitor_th = new std::thread(battery_monitor);
return ::ndk::ScopedAStatus::ok();
}