Skip to content

Commit

Permalink
Merge pull request #474 from SteamRE/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
xPaw committed Feb 9, 2024
2 parents 93318f2 + 0f00ea5 commit 9d24464
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 291 deletions.
20 changes: 8 additions & 12 deletions DepotDownloader/AccountSettingsStore.cs
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
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

0 comments on commit 9d24464

Please sign in to comment.