Merge "Assure associate callback is called in msgTask"

This commit is contained in:
Linux Build Service Account 2014-04-18 13:42:24 -07:00 committed by Gerrit - the friendly Code Review server
commit 3c8b3ff4fd
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) { if (NULL == mMsgTask) {
mMsgTask = new MsgTask(tAssociate, name); mMsgTask = new MsgTask(tAssociate, name);
} else if (tAssociate) {
mMsgTask->associate(tAssociate);
} }
return mMsgTask; return mMsgTask;
} }

View file

@ -69,6 +69,21 @@ MsgTask::~MsgTask() {
msg_q_unblock((void*)mQ); 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) { void MsgTask::createPThread(const char* threadName) {
pthread_attr_t attr; pthread_attr_t attr;
pthread_attr_init(&attr); pthread_attr_init(&attr);

View file

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