Assure associate callback is called in msgTask

If MsgTask thread is created before context that
has associator is initialized, the associator
callback was not getting called.

CRs-fixed: 650061

Change-Id: I45d81e1b49fc8dcbc93d1ceef4fef38468ecb4f8
This commit is contained in:
Dante Russo 2014-04-15 17:38:42 -07:00
parent 3d86280b90
commit 996a633c02
3 changed files with 18 additions and 0 deletions

View file

@ -74,6 +74,8 @@ const MsgTask* LocDualContext::getMsgTask(MsgTask::tAssociate tAssociate,
{
if (NULL == mMsgTask) {
mMsgTask = new MsgTask(tAssociate, name);
} else if (tAssociate) {
mMsgTask->associate(tAssociate);
}
return mMsgTask;
}

View file

@ -69,6 +69,21 @@ MsgTask::~MsgTask() {
msg_q_unblock((void*)mQ);
}
void MsgTask::associate(tAssociate tAssociator) const {
struct LocAssociateMsg : public LocMsg {
tAssociate mAssociator;
inline LocAssociateMsg(tAssociate associator) :
LocMsg(), mAssociator(associator) {}
inline virtual void proc() const {
if (mAssociator) {
LOC_LOGD("MsgTask::associate");
mAssociator();
}
}
};
sendMsg(new LocAssociateMsg(tAssociator));
}
void MsgTask::createPThread(const char* threadName) {
pthread_attr_t attr;
pthread_attr_init(&attr);

View file

@ -52,6 +52,7 @@ public:
MsgTask(tAssociate tAssociator, const char* threadName);
~MsgTask();
void sendMsg(const LocMsg* msg) const;
void associate(tAssociate tAssociator) const;
private:
const void* mQ;