Example #1
0
void* pushMessage(void* para) 
{
    ThreadPara* threadPara = (ThreadPara*)para;
    TaskQueue* pQueue = threadPara->pQueue;
    UpdateAction nAction = threadPara->nAction;

    if (pQueue == NULL) {
        return NULL;
    }

    while (1) {
        const char *pFile = NULL;

        threadPara->lock->lock();
        if (pQueue->size() == 0) {
            threadPara->lock->unlock();
            break;
        }
        pFile = pQueue->back();
        pQueue->popBack();
        threadPara->lock->unlock();

        if (pFile == NULL) {
            break;
        }
        if (ACTION_ADD == nAction) {
            TNOTE("pushing add file %s", pFile);
            pushAddMessage(threadPara->api, pFile);
        }
        else {
            TNOTE("pushing del file %s", pFile);
            pushDelMessage(threadPara->api, pFile);
        }
        delete[] pFile;
        pFile = NULL;
    }

    return NULL;
}