-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
227 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,93 @@ | ||
namespace Sucrose.Backgroundog.Helper | ||
using SBEL = Sucrose.Backgroundog.Extension.Lifecycle; | ||
using SBMI = Sucrose.Backgroundog.Manage.Internal; | ||
using SBMM = Sucrose.Backgroundog.Manage.Manager; | ||
using SMMM = Sucrose.Manager.Manage.Manager; | ||
using SSDECPT = Sucrose.Shared.Dependency.Enum.CategoryPerformanceType; | ||
using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType; | ||
using SSLHR = Sucrose.Shared.Live.Helper.Run; | ||
using SSSHL = Sucrose.Shared.Space.Helper.Live; | ||
using SSSHP = Sucrose.Shared.Space.Helper.Processor; | ||
|
||
namespace Sucrose.Backgroundog.Helper | ||
{ | ||
internal static class Condition | ||
{ | ||
public static async Task Start() | ||
{ | ||
Console.WriteLine("Condition"); | ||
//Performans şartları sağlanıp live motoru kapatıldıysa veya durdurulduysa | ||
//Live motoruna gRPC (Live.json) ile durdur mesajı gönderilir | ||
|
||
if (SBMI.Performance == SSDEPT.Pause && ((SBMI.App != null && SBMI.App.HasExited) || (SBMI.Live != null && SBMI.Live.HasExited))) | ||
{ | ||
SBMI.Condition = false; | ||
SBMI.Performance = SSDEPT.Resume; | ||
SBMI.CategoryPerformance = SSDECPT.Not; | ||
} | ||
else | ||
{ | ||
if (await CpuCondition()) | ||
{ | ||
return; | ||
} | ||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
|
||
private static void Lifecycle() | ||
{ | ||
if (SBMI.Performance == SSDEPT.Close) | ||
{ | ||
SSLHR.Start(); | ||
} | ||
else | ||
{ | ||
SBMI.Live = SSSHL.Get(); | ||
|
||
if (SBMI.Live != null && !SBMI.Live.HasExited) | ||
{ | ||
SBEL.Resume(SBMI.Live); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(SMMM.App)) | ||
{ | ||
SBMI.App = SSSHP.Get(SMMM.App); | ||
|
||
if (SBMI.App != null && !SBMI.App.HasExited) | ||
{ | ||
SBEL.Resume(SBMI.App); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static async Task<bool> CpuCondition() | ||
{ | ||
if (SBMI.CategoryPerformance == SSDECPT.Cpu) | ||
{ | ||
int Count = 0; | ||
int MaxCount = 3; | ||
|
||
while (SBMI.CpuData.Now < SMMM.CpuUsage || SBMM.CpuPerformance == SSDEPT.Resume) | ||
{ | ||
if (Count >= MaxCount) | ||
{ | ||
Lifecycle(); | ||
SBMI.Condition = false; | ||
SBMI.Performance = SSDEPT.Resume; | ||
SBMI.CategoryPerformance = SSDECPT.Not; | ||
|
||
return true; | ||
} | ||
else | ||
{ | ||
Count++; | ||
} | ||
|
||
await Task.Delay(TimeSpan.FromSeconds(1)); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters