Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FailedProxyCache.cs
Go to the documentation of this file.
5
6namespace System.Net.Http;
7
8internal sealed class FailedProxyCache
9{
11
12 private long _nextFlushTicks = Environment.TickCount64 + 300000;
13
15
16 public long GetProxyRenewTicks(Uri uri)
17 {
18 Cleanup();
20 {
21 return 0L;
22 }
24 {
25 return value;
26 }
27 if (TryRenewProxy(uri, value))
28 {
29 return 0L;
30 }
32 {
33 return 0L;
34 }
35 return value;
36 }
37
38 public void SetProxyFailed(Uri uri)
39 {
40 _failedProxies[uri] = Environment.TickCount64 + 1800000;
41 Cleanup();
42 }
43
44 public bool TryRenewProxy(Uri uri, long renewTicks)
45 {
46 return _failedProxies.TryRemove(new KeyValuePair<Uri, long>(uri, renewTicks));
47 }
48
49 [MethodImpl(MethodImplOptions.AggressiveInlining)]
50 private void Cleanup()
51 {
53 {
55 }
56 }
57
58 [MethodImpl(MethodImplOptions.NoInlining)]
59 private void CleanupHelper()
60 {
61 bool lockTaken = false;
62 try
63 {
65 if (!lockTaken)
66 {
67 return;
68 }
69 long tickCount = Environment.TickCount64;
71 {
72 if (tickCount >= failedProxy.Value)
73 {
75 }
76 }
77 }
78 finally
79 {
80 if (lockTaken)
81 {
84 }
85 }
86 }
87}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
static long TickCount64
readonly ConcurrentDictionary< Uri, long > _failedProxies
bool TryRenewProxy(Uri uri, long renewTicks)
static int Exchange(ref int location1, int value)
static long Read(ref long location)
void TryEnter(ref bool lockTaken)
Definition SpinLock.cs:103