summaryrefslogtreecommitdiff
path: root/utils/MsgTask.cpp
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2015-09-11 19:40:25 -0700
committerKevin Tang <zhikait@codeaurora.org>2015-09-21 14:45:58 -0700
commit94ecbf68045cb44f6b6287621007ac845ed88ee2 (patch)
tree238cfd22f18ec89b97d1342d8276cc61fb716fa5 /utils/MsgTask.cpp
parent049cc84d3a9df23f92fda74845c5f4dd95507c23 (diff)
downloadgps-94ecbf68045cb44f6b6287621007ac845ed88ee2.tar.gz
Crash fix with MsgTask API change
Removed tCreate and tAssociate from MsgTask. LocThread now can optionally take a tCreate method. Associator is replaced with *firstMsg* option to MsgTask, which is a more generic option, that can associate or do other set up job at the create of a MsgTask. The current MsgTask doesn't use tCreate, which exposes a slight time window for Location HAL when its MsgTask is NOT associated to DVM heap but a message delivery to DVM could be attempted during this time. Change-Id: Iafd5b91b693baacb9b7064463f8c44f74026f54c CRs-Fixed: 902350
Diffstat (limited to 'utils/MsgTask.cpp')
-rw-r--r--utils/MsgTask.cpp44
1 files changed, 9 insertions, 35 deletions
diff --git a/utils/MsgTask.cpp b/utils/MsgTask.cpp
index 794bf92..fdb1102 100644
--- a/utils/MsgTask.cpp
+++ b/utils/MsgTask.cpp
@@ -36,12 +36,19 @@
#include <log_util.h>
#include <loc_log.h>
-namespace loc_core {
-
static void LocMsgDestroy(void* msg) {
delete (LocMsg*)msg;
}
+MsgTask::MsgTask(LocThread::tCreate tCreator,
+ const char* threadName, bool joinable) :
+ mQ(msg_q_init2()), mThread(new LocThread()) {
+ if (!mThread->start(tCreator, threadName, this, joinable)) {
+ delete mThread;
+ mThread = NULL;
+ }
+}
+
MsgTask::MsgTask(const char* threadName, bool joinable) :
mQ(msg_q_init2()), mThread(new LocThread()) {
if (!mThread->start(threadName, this, joinable)) {
@@ -93,36 +100,3 @@ bool MsgTask::run() {
return true;
}
-
-// TODO: remove the below in the next patch
-void MsgTask::associate(tAssociate tAssociator) const {
- struct LocAssociateMsg : public LocMsg {
- tAssociate mAssociator;
- LocAssociateMsg(tAssociate associator) :
- mAssociator(associator) {}
- inline virtual void proc() const {
- mAssociator();
- }
- };
- sendMsg(new LocAssociateMsg(tAssociator));
-}
-
-MsgTask::MsgTask(tCreate tCreator, const char* threadName) :
- mQ(msg_q_init2()), mThread(new LocThread()) {
- if (!mThread->start(threadName, this, false)) {
- delete mThread;
- mThread = NULL;
- }
-}
-
-MsgTask::MsgTask(tAssociate tAssociator, const char* threadName) :
- mQ(msg_q_init2()), mThread(new LocThread()) {
- if (!mThread->start(threadName, this, false)) {
- delete mThread;
- mThread = NULL;
- } else if (tAssociator != NULL){
- associate(tAssociator);
- }
-}
-
-} // namespace loc_core