Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #474

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions DepotDownloader/AccountSettingsStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class AccountSettingsStore
AccountSettingsStore()
{
ContentServerPenalty = new ConcurrentDictionary<string, int>();
LoginTokens = new Dictionary<string, string>();
GuardData = new Dictionary<string, string>();
LoginTokens = [];
GuardData = [];
}

static bool Loaded
Expand All @@ -50,11 +50,9 @@ public static void LoadFromFile(string filename)
{
try
{
using (var fs = IsolatedStorage.OpenFile(filename, FileMode.Open, FileAccess.Read))
using (var ds = new DeflateStream(fs, CompressionMode.Decompress))
{
Instance = Serializer.Deserialize<AccountSettingsStore>(ds);
}
using var fs = IsolatedStorage.OpenFile(filename, FileMode.Open, FileAccess.Read);
using var ds = new DeflateStream(fs, CompressionMode.Decompress);
Instance = Serializer.Deserialize<AccountSettingsStore>(ds);
}
catch (IOException ex)
{
Expand All @@ -77,11 +75,9 @@ public static void Save()

try
{
using (var fs = IsolatedStorage.OpenFile(Instance.FileName, FileMode.Create, FileAccess.Write))
using (var ds = new DeflateStream(fs, CompressionMode.Compress))
{
Serializer.Serialize(ds, Instance);
}
using var fs = IsolatedStorage.OpenFile(Instance.FileName, FileMode.Create, FileAccess.Write);
using var ds = new DeflateStream(fs, CompressionMode.Compress);
Serializer.Serialize(ds, Instance);
}
catch (IOException ex)
{
Expand Down
14 changes: 4 additions & 10 deletions DepotDownloader/CDNClientPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class CDNClientPool
public Client CDNClient { get; }
public Server ProxyServer { get; private set; }

private readonly ConcurrentStack<Server> activeConnectionPool;
private readonly BlockingCollection<Server> availableServerEndpoints;
private readonly ConcurrentStack<Server> activeConnectionPool = [];
private readonly BlockingCollection<Server> availableServerEndpoints = [];

private readonly AutoResetEvent populatePoolEvent;
private readonly AutoResetEvent populatePoolEvent = new(true);
private readonly Task monitorTask;
private readonly CancellationTokenSource shutdownToken;
private readonly CancellationTokenSource shutdownToken = new();
public CancellationTokenSource ExhaustedToken { get; set; }

public CDNClientPool(Steam3Session steamSession, uint appId)
Expand All @@ -34,12 +34,6 @@ public CDNClientPool(Steam3Session steamSession, uint appId)
this.appId = appId;
CDNClient = new Client(steamSession.steamClient);

activeConnectionPool = new ConcurrentStack<Server>();
availableServerEndpoints = new BlockingCollection<Server>();

populatePoolEvent = new AutoResetEvent(true);
shutdownToken = new CancellationTokenSource();

monitorTask = Task.Factory.StartNew(ConnectionPoolMonitorAsync).Unwrap();
}

Expand Down
Loading
Loading