summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2020-08-13 22:02:18 -0700
committerKevin Tang <zhikait@codeaurora.org>2020-09-09 10:22:48 -0700
commit68eb016da6c264aaabebdcdca67a03ee4f38d5a5 (patch)
tree227e047199e193c07d94123070d59b169e8f8096 /core
parented1e71bdcc1f2676685fc903d01f3fb0aca8cc99 (diff)
gps.utils changes
* Replaced the use of pthread in the implementation of LocThread with std::thread. * Removed the support of joinable thread from LocThread API, as it is never needed. * MsgTask no longer derives from LocRunnable, so that it can be directly deleted by ownerer. * Removed tCreator from LocThread::start() as well as LocContext::getLocContext(). * Placed utils classes under loc_utils namespace. Change-Id: Ia6b29debbf92c48aa643574b1d3789da686f5c73 CRs-Fixed: 2770806
Diffstat (limited to 'core')
-rw-r--r--core/ContextBase.h2
-rw-r--r--core/EngineHubProxyBase.h2
-rw-r--r--core/LocApiBase.cpp2
-rw-r--r--core/LocApiBase.h4
-rw-r--r--core/LocContext.cpp21
-rw-r--r--core/LocContext.h12
6 files changed, 16 insertions, 27 deletions
diff --git a/core/ContextBase.h b/core/ContextBase.h
index 85095c4..026ab49 100644
--- a/core/ContextBase.h
+++ b/core/ContextBase.h
@@ -110,6 +110,8 @@ typedef struct
double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
} loc_sap_cfg_s_type;
+using namespace loc_util;
+
namespace loc_core {
class LocAdapterBase;
diff --git a/core/EngineHubProxyBase.h b/core/EngineHubProxyBase.h
index f7fe4d2..13a1cd7 100644
--- a/core/EngineHubProxyBase.h
+++ b/core/EngineHubProxyBase.h
@@ -31,6 +31,8 @@
namespace loc_core {
+using namespace loc_util;
+
class EngineHubProxyBase {
public:
inline EngineHubProxyBase() {
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index 55ba72e..6685add 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -160,7 +160,7 @@ LocApiBase::LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
android_atomic_inc(&mMsgTaskRefCount);
if (nullptr == mMsgTask) {
- mMsgTask = new MsgTask("LocApiMsgTask", false);
+ mMsgTask = new MsgTask("LocApiMsgTask");
}
}
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index db0f490..0c7baa5 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -37,6 +37,8 @@
#include <LocSharedLock.h>
#include <log_util.h>
+using namespace loc_util;
+
namespace loc_core {
class ContextBase;
@@ -120,7 +122,7 @@ protected:
inline virtual ~LocApiBase() {
android_atomic_dec(&mMsgTaskRefCount);
if (nullptr != mMsgTask && 0 == mMsgTaskRefCount) {
- mMsgTask->destroy();
+ delete mMsgTask;
mMsgTask = nullptr;
}
}
diff --git a/core/LocContext.cpp b/core/LocContext.cpp
index 18d3f2d..272c08c 100644
--- a/core/LocContext.cpp
+++ b/core/LocContext.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, 2016-2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, 2016-2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -50,36 +50,25 @@ const char* LocContext::mLBSLibName = "liblbs_core.so.1";
pthread_mutex_t LocContext::mGetLocContextMutex = PTHREAD_MUTEX_INITIALIZER;
-const MsgTask* LocContext::getMsgTask(LocThread::tCreate tCreator,
- const char* name, bool joinable)
+const MsgTask* LocContext::getMsgTask(const char* name)
{
if (NULL == mMsgTask) {
- mMsgTask = new MsgTask(tCreator, name, joinable);
+ mMsgTask = new MsgTask(name);
}
return mMsgTask;
}
-inline
-const MsgTask* LocContext::getMsgTask(const char* name, bool joinable) {
- return getMsgTask((LocThread::tCreate)NULL, name, joinable);
-}
-
-ContextBase* LocContext::getLocContext(LocThread::tCreate tCreator,
- LocMsg* firstMsg, const char* name, bool joinable)
+ContextBase* LocContext::getLocContext(const char* name)
{
pthread_mutex_lock(&LocContext::mGetLocContextMutex);
LOC_LOGD("%s:%d]: querying ContextBase with tCreator", __func__, __LINE__);
if (NULL == mContext) {
LOC_LOGD("%s:%d]: creating msgTask with tCreator", __func__, __LINE__);
- const MsgTask* msgTask = getMsgTask(tCreator, name, joinable);
+ const MsgTask* msgTask = getMsgTask(name);
mContext = new LocContext(msgTask);
}
pthread_mutex_unlock(&LocContext::mGetLocContextMutex);
- if (firstMsg) {
- mContext->sendMsg(firstMsg);
- }
-
return mContext;
}
diff --git a/core/LocContext.h b/core/LocContext.h
index fb7d009..628ed93 100644
--- a/core/LocContext.h
+++ b/core/LocContext.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, 2017-2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, 2017-2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -39,9 +39,7 @@ namespace loc_core {
class LocContext : public ContextBase {
static const MsgTask* mMsgTask;
static ContextBase* mContext;
- static const MsgTask* getMsgTask(LocThread::tCreate tCreator,
- const char* name, bool joinable = true);
- static const MsgTask* getMsgTask(const char* name, bool joinable = true);
+ static const MsgTask* getMsgTask(const char* name);
static pthread_mutex_t mGetLocContextMutex;
protected:
@@ -52,11 +50,7 @@ public:
static const char* mLBSLibName;
static const char* mLocationHalName;
- static ContextBase* getLocContext(LocThread::tCreate tCreator, LocMsg* firstMsg,
- const char* name, bool joinable = true);
- inline static ContextBase* getLocContext(const char* name, bool joinable = true) {
- return getLocContext(NULL, NULL, name, joinable);
- }
+ static ContextBase* getLocContext(const char* name);
static void injectFeatureConfig(ContextBase *context);
};