MCPcopy Create free account
hub / github.com/9miao/CrossApp / dispatchResponseCallbacks

Method dispatchResponseCallbacks

CrossApp/support/network/HttpClient.cpp:470–504  ·  view source on GitHub ↗

Poll and notify main thread if responses exists in queue

Source from the content-addressed store, hash-verified

468
469// Poll and notify main thread if responses exists in queue
470void CAHttpClient::dispatchResponseCallbacks(float delta)
471{
472 CAHttpResponse* response = NULL;
473
474 pthread_mutex_lock(&s_responseQueueMutex);
475 if (!s_responseQueue.empty())
476 {
477 response = s_responseQueue.front();
478 s_responseQueue.popFront();
479 }
480 pthread_mutex_unlock(&s_responseQueueMutex);
481
482 if (response)
483 {
484 --_asyncRequestCount;
485
486 CAHttpRequest *request = response->getHttpRequest();
487 CC_RETURN_IF(request == NULL);
488 CAObject *pTarget = request->getTarget();
489 SEL_HttpResponse pSelector = request->getSelector();
490
491 if (pTarget && pSelector)
492 {
493 (pTarget->*pSelector)(this, response);
494 }
495
496 response->release();
497 }
498
499 if (0 == _asyncRequestCount)
500 {
501 CAScheduler::getScheduler()->pauseTarget(this);
502 }
503
504}
505
506
507NS_CC_END

Callers

nothing calls this directly

Calls 8

pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
pauseTargetMethod · 0.80
emptyMethod · 0.45
popFrontMethod · 0.45
getTargetMethod · 0.45
getSelectorMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected