MCPcopy Create free account
hub / github.com/ProjectBorealis/UEGitPlugin / Run

Method Run

Source/GitSourceControl/Private/GitSourceControlRunner.cpp:34–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34uint32 FGitSourceControlRunner::Run()
35{
36 while (bRunThread)
37 {
38 StopEvent->Wait(30000);
39 if (!bRunThread)
40 {
41 break;
42 }
43 // If we're not running the task already
44 if (!bRefreshSpawned)
45 {
46 // Flag that we're running the task already
47 bRefreshSpawned = true;
48 const auto ExecuteResult = Async(EAsyncExecution::TaskGraphMainThread, [this] {
49 FGitSourceControlModule* GitSourceControl = FGitSourceControlModule::GetThreadSafe();
50 // Module not loaded, bail. Usually happens when editor is shutting down, and this prevents a crash from bad timing.
51 if (!GitSourceControl)
52 {
53 return ECommandResult::Failed;
54 }
55 FGitSourceControlProvider& Provider = GitSourceControl->GetProvider();
56 TSharedRef<FGitFetch, ESPMode::ThreadSafe> RefreshOperation = ISourceControlOperation::Create<FGitFetch>();
57 RefreshOperation->bUpdateStatus = true;
58#if ENGINE_MAJOR_VERSION >= 5
59 const ECommandResult::Type Result = Provider.Execute(RefreshOperation, FSourceControlChangelistPtr(), FGitSourceControlModule::GetEmptyStringArray(), EConcurrency::Asynchronous,
60 FSourceControlOperationComplete::CreateRaw(this, &FGitSourceControlRunner::OnSourceControlOperationComplete));
61#else
62 const ECommandResult::Type Result = Provider.Execute(RefreshOperation, FGitSourceControlModule::GetEmptyStringArray(), EConcurrency::Asynchronous,
63 FSourceControlOperationComplete::CreateRaw(this, &FGitSourceControlRunner::OnSourceControlOperationComplete));
64#endif
65 return Result;
66 });
67 // Wait for result if not already completed
68 if (bRefreshSpawned && bRunThread)
69 {
70 // Get the result
71 ECommandResult::Type Result = ExecuteResult.Get();
72 // If still not completed,
73 if (bRefreshSpawned)
74 {
75 // mark failures as done, successes have to complete
76 bRefreshSpawned = Result == ECommandResult::Succeeded;
77 }
78 }
79 }
80 }
81
82 return 0;
83}
84
85void FGitSourceControlRunner::Stop()
86{

Callers

nothing calls this directly

Calls 2

GetMethod · 0.80
ExecuteMethod · 0.45

Tested by

no test coverage detected