MCPcopy Create free account
hub / github.com/catboost/catboost / MetaThreadFunction

Method MetaThreadFunction

library/cpp/par/par_remote.cpp:473–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471 }
472
473 void TRemoteQueryProcessor::MetaThreadFunction() {
474 while (DoRun) {
475 TNetworkEvent netEvent;
476 while (NetworkEventsQueue.Dequeue(&netEvent)) {
477 if (netEvent.EventType == TNetworkEvent::EType::IcomingQueryCancel) {
478 TIntrusivePtr<TQueryResultDst> queryInfoPtr;
479 if (!IncomingRequestsData.ExtractValueIfPresent(netEvent.ReqId, queryInfoPtr)) {
480 continue;
481 }
482 for (auto& callback : queryInfoPtr->CallbackVector) {
483 callback->OnCancel();
484 }
485 } else if (netEvent.EventType == TNetworkEvent::EType::IncomingQuery) {
486 if (!CmdProcessors.contains(netEvent.Request->Url)) {
487 if (netEvent.Request->Url == "check_stop") {
488 TVector<char> tmp;
489 tmp.push_back(RequestsData.Empty());
490 Requester->SendResponse(netEvent.Request->ReqId, &tmp);
491 } else {
492 Y_ASSERT(0);
493 }
494 } else {
495 IncomingRequestsData.EmplaceValue(netEvent.Request->ReqId, new TQueryResultDst);
496 CmdProcessors.at(netEvent.Request->Url)->NewRequest(this, netEvent.Request.Get());
497 }
498 } else if (netEvent.EventType == TNetworkEvent::EType::ReplyReceived) {
499 TIntrusivePtr<TQueryResultDst> queryInfoPtr;
500 if (!RequestsData.ExtractValueIfPresent(netEvent.Response->ReqId, queryInfoPtr)) {
501 continue;
502 }
503
504 if (netEvent.Response->Status == TNetworkResponse::EStatus::Canceled) {
505 PAR_DEBUG_LOG << "At " << Requester->GetHostAndPort() << " Query " << GetGuidAsString(netEvent.Response->ReqId) << " cancelled" << Endl;
506 } else if (netEvent.Response->Status == TNetworkResponse::EStatus::Ok) {
507 static TTiming& queryFullTime = TParHostStats::GetTiming(ETimingTag::QueryFullTime);
508 queryFullTime += (TInstant::Now() - queryInfoPtr->QueryCreationTime).SecondsFloat();
509 queryInfoPtr->Proc->GotResponse(queryInfoPtr->Id, &netEvent.Response->Data);
510 } else {
511 Y_ABORT();
512 }
513 }
514 }
515 if (!NetworkEventsQueue.IsEmpty()) {
516 continue;
517 }
518 NetworkEvent.WaitT(TDuration::MilliSeconds(500));
519 }
520 }
521}

Callers

nothing calls this directly

Calls 15

GetGuidAsStringFunction · 0.85
MilliSecondsFunction · 0.85
ExtractValueIfPresentMethod · 0.80
EmplaceValueMethod · 0.80
GetHostAndPortMethod · 0.80
SecondsFloatMethod · 0.80
NowFunction · 0.50
DequeueMethod · 0.45
OnCancelMethod · 0.45
containsMethod · 0.45
push_backMethod · 0.45
EmptyMethod · 0.45

Tested by

no test coverage detected