Merge "Delete LocApiBase and derived class on msgTask thread"
This commit is contained in:
commit
148224c378
2 changed files with 29 additions and 3 deletions
|
@ -124,7 +124,16 @@ public:
|
||||||
ContextBase(const MsgTask* msgTask,
|
ContextBase(const MsgTask* msgTask,
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
||||||
const char* libName);
|
const char* libName);
|
||||||
inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; }
|
inline virtual ~ContextBase() {
|
||||||
|
if (nullptr != mLocApi) {
|
||||||
|
mLocApi->destroy();
|
||||||
|
mLocApi = nullptr;
|
||||||
|
}
|
||||||
|
if (nullptr != mLBSProxy) {
|
||||||
|
delete mLBSProxy;
|
||||||
|
mLBSProxy = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||||
inline LocApiBase* getLocApi() { return mLocApi; }
|
inline LocApiBase* getLocApi() { return mLocApi; }
|
||||||
|
|
|
@ -103,11 +103,11 @@ class LocApiBase {
|
||||||
//it as a friend
|
//it as a friend
|
||||||
friend struct LocOpenMsg;
|
friend struct LocOpenMsg;
|
||||||
friend struct LocCloseMsg;
|
friend struct LocCloseMsg;
|
||||||
|
friend struct LocKillMsg;
|
||||||
friend class ContextBase;
|
friend class ContextBase;
|
||||||
static MsgTask* mMsgTask;
|
static MsgTask* mMsgTask;
|
||||||
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
|
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ContextBase *mContext;
|
ContextBase *mContext;
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
|
@ -118,7 +118,12 @@ protected:
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
||||||
LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
|
LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
|
||||||
ContextBase* context = NULL);
|
ContextBase* context = NULL);
|
||||||
inline virtual ~LocApiBase() { close(); }
|
inline virtual ~LocApiBase() {
|
||||||
|
if (nullptr != mMsgTask) {
|
||||||
|
mMsgTask->destroy();
|
||||||
|
mMsgTask = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool isInSession();
|
bool isInSession();
|
||||||
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
||||||
bool isMaster();
|
bool isMaster();
|
||||||
|
@ -127,6 +132,18 @@ public:
|
||||||
inline void sendMsg(const LocMsg* msg) const {
|
inline void sendMsg(const LocMsg* msg) const {
|
||||||
mMsgTask->sendMsg(msg);
|
mMsgTask->sendMsg(msg);
|
||||||
}
|
}
|
||||||
|
inline void destroy() {
|
||||||
|
close();
|
||||||
|
struct LocKillMsg : public LocMsg {
|
||||||
|
LocApiBase* mLocApi;
|
||||||
|
inline LocKillMsg(LocApiBase* locApi) : LocMsg(), mLocApi(locApi) {}
|
||||||
|
inline virtual void proc() const {
|
||||||
|
delete mLocApi;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sendMsg(new LocKillMsg(this));
|
||||||
|
}
|
||||||
|
|
||||||
void addAdapter(LocAdapterBase* adapter);
|
void addAdapter(LocAdapterBase* adapter);
|
||||||
void removeAdapter(LocAdapterBase* adapter);
|
void removeAdapter(LocAdapterBase* adapter);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue