Changeset 392 for binary-improvements2/7dtd-server-fixes/src
- Timestamp:
- Aug 8, 2022, 8:04:09 PM (2 years ago)
- Location:
- binary-improvements2/7dtd-server-fixes/src/FileCache
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/7dtd-server-fixes/src/FileCache/AbstractCache.cs
r351 r392 1 using System.Collections.Generic; 2 1 3 namespace AllocsFixes.FileCache { 2 4 public abstract class AbstractCache { 3 5 public abstract byte[] GetFileContent (string _filename); 6 public abstract (int, int) Invalidate (); 7 8 protected AbstractCache () { 9 caches.Add (this); 10 } 11 12 private static readonly List<AbstractCache> caches = new List<AbstractCache> (); 13 public static (int, int) InvalidateAllCaches () { 14 int filesDropped = 0; 15 int bytesDropped = 0; 16 17 foreach (AbstractCache cache in caches) { 18 (int, int) returned = cache.Invalidate (); 19 filesDropped += returned.Item1; 20 bytesDropped += returned.Item2; 21 } 22 23 return (filesDropped, bytesDropped); 24 } 4 25 } 5 26 } -
binary-improvements2/7dtd-server-fixes/src/FileCache/DirectAccess.cs
r391 r392 14 14 return null; 15 15 } 16 17 public override (int, int) Invalidate () { 18 return (0, 0); 19 } 16 20 } 17 21 } -
binary-improvements2/7dtd-server-fixes/src/FileCache/MapTileCache.cs
r391 r392 114 114 } 115 115 116 public override (int, int) Invalidate () { 117 return (0, 0); 118 } 119 116 120 private static byte[] ReadAllBytes (string _path) { 117 121 using (FileStream fileStream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.Read, 4096)) { -
binary-improvements2/7dtd-server-fixes/src/FileCache/SimpleCache.cs
r391 r392 29 29 return null; 30 30 } 31 32 public override (int, int) Invalidate () { 33 (int, int) result = (0, 0); 34 35 lock (fileCache) { 36 result.Item1 = fileCache.Count; 37 foreach ((string _, byte[] data) in fileCache) { 38 result.Item2 += data.Length; 39 } 40 41 fileCache.Clear (); 42 } 43 44 return result; 45 } 31 46 } 32 47 }
Note:
See TracChangeset
for help on using the changeset viewer.