MCPcopy Create free account
hub / github.com/beefytech/Beef / Get

Method Get

IDEHelper/NetManager.cpp:527–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527bool NetManager::Get(const StringImpl& url, const StringImpl& destPath)
528{
529 NetRequest* netRequest = NULL;
530 int waitCount = 0;
531 while (true)
532 {
533 // Check cached
534 {
535 AutoCrit autoCrit(mThreadPool.mCritSect);
536
537 mWaitingResult = NULL;
538 NetResult* netResult;
539 if (mCachedResults.TryGetValue(url, &netResult))
540 {
541 if (netResult->mCurRequest == NULL)
542 {
543 BfLogDbg("NetManager::Get using cached result for %s: %d. WaitCount: %d \n", url.c_str(), !netResult->mFailed, waitCount);
544 return (!netResult->mFailed) && (FileExists(netResult->mOutPath));
545 }
546 else if (!netResult->mCurRequest->mShowTracking) // Is done?
547 {
548 if (!netResult->mCurRequest->mProcessing)
549 {
550 BfLogDbg("NetManager::Get pulling queued request into current thread %s\n", url.c_str());
551 netRequest = netResult->mCurRequest;
552 bool didRemove = mThreadPool.mJobs.Remove(netRequest);
553 BF_ASSERT(didRemove);
554 break;
555 }
556
557 mWaitingResult = netResult;
558 netResult->mCurRequest->ShowTracking();
559 }
560 }
561 else
562 {
563 netRequest = CreateGetRequest(url, destPath, true);
564 break;
565 }
566 }
567
568 waitCount++;
569 mRequestDoneEvent.WaitFor();
570 }
571
572 // Perform this in the requesting thread
573 {
574 AutoCrit autoCrit(mThreadPool.mCritSect);
575 mWaitingRequest = netRequest;
576 }
577
578 netRequest->mShowTracking = true;
579 netRequest->Perform();
580
581 AutoCrit autoCrit(mThreadPool.mCritSect);
582 mWaitingRequest = NULL;
583 auto netResult = netRequest->mResult;
584 delete netRequest;

Callers

nothing calls this directly

Calls 7

TryGetValueMethod · 0.80
ShowTrackingMethod · 0.80
WaitForMethod · 0.80
c_strMethod · 0.45
RemoveMethod · 0.45
PerformMethod · 0.45
OutputRawMessageMethod · 0.45

Tested by

no test coverage detected