Skip to content

Commit

Permalink
Make max tasks core dependant
Browse files Browse the repository at this point in the history
  • Loading branch information
Drommedhar committed Oct 10, 2024
1 parent db2c8a9 commit ee9707a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion DlssUpdater/GameLibrary/EpicGames/EpicGamesLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Text.Json;
using System.Xml.Linq;
using DlssUpdater;
using DlssUpdater.GameLibrary;
using DlssUpdater.Helpers;
using DLSSUpdater.Defines;
Expand Down Expand Up @@ -91,7 +92,7 @@ private async Task<List<GameInfo>> getGames()
}

List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: 10);
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
var files = Directory.GetFiles(path);
foreach (var file in files)
{
Expand Down
3 changes: 2 additions & 1 deletion DlssUpdater/GameLibrary/GOGLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using System.Text.Json;
using DlssUpdater;
using DlssUpdater.GameLibrary;
using DlssUpdater.Helpers;
using DLSSUpdater.Defines;
Expand Down Expand Up @@ -52,7 +53,7 @@ private async Task<List<GameInfo>> getGames()
}

List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: 10);
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
foreach (var subKey in subKeys)
{
var task = Task.Run(async () =>
Expand Down
2 changes: 1 addition & 1 deletion DlssUpdater/GameLibrary/Steam/SteamLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private async Task<List<GameInfo>> getGames(List<LibraryFolder> folder)
List<Task> tasks = [];
List<GameInfo> ret = [];

var throttler = new SemaphoreSlim(initialCount: 10);
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);

foreach (var folderItem in folder)
{
Expand Down
2 changes: 1 addition & 1 deletion DlssUpdater/GameLibrary/UbisoftConnectLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private async Task<List<GameInfo>> getGames()
var data = await File.ReadAllTextAsync(configPath);
var entries = data.Split("root:", StringSplitOptions.TrimEntries);
List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: 10);
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
foreach (var entry in entries)
{
var task = Task.Run(async () =>
Expand Down
2 changes: 1 addition & 1 deletion DlssUpdater/GameLibrary/XboxLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void GetInstallationDirectory()
private async Task<List<GameInfo>> getGames()
{
List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: 10);
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
List<GameInfo> ret = [];

var drive = DriveInfo.GetDrives();
Expand Down
1 change: 1 addition & 0 deletions DlssUpdater/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static class Constants
public static string CacheFile { get; } = "cache.json";
public static string SettingsFile { get; } = "settings.json";
public static TimeSpan CacheTime { get; } = TimeSpan.FromMinutes(30);
public static int CoreCount { get; } = Environment.ProcessorCount;
}

public class Paths
Expand Down

0 comments on commit ee9707a

Please sign in to comment.