You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Co-Authored-By: ACrazyTown <47027981+ACrazyTown@users.noreply.github.com>
Co-Authored-By: Kolo <67389779+KoloInDaCrib@users.noreply.github.com>
Co-Authored-By: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com>
// Used to track the state we're in while loading the characters. This can either be us loading all character data, or loading each scripted character types.
Copy file name to clipboardExpand all lines: source/funkin/util/assets/StagedCache.hx
+28-2Lines changed: 28 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,9 @@
1
1
packagefunkin.util.assets;
2
2
3
3
importflixel.util.FlxSignal.FlxTypedSignal;
4
+
#if FEATURE_MULTITHREADING
5
+
importhx.concurrent.collection.SynchronizedMap;
6
+
#end
4
7
5
8
/**
6
9
* Represents a three-stage asset cache, which is useful for managing and tracking assets that are in use by the game.
@@ -12,17 +15,27 @@ class StagedCache<T> implements IStagedCache
12
15
/**
13
16
* The permanent cache, containing assets which always stay in memory and are never purged.
14
17
*/
18
+
#if FEATURE_MULTITHREADING
19
+
finalpermanent:SynchronizedMap<String, T>;
20
+
#else
15
21
finalpermanent:Map<String, T>;
16
-
22
+
#end
17
23
/**
18
24
* The currently cached assets. Won't be purged until the next purge cycle.
19
25
*/
26
+
#if FEATURE_MULTITHREADING
27
+
finalcurrent:SynchronizedMap<String, T>;
28
+
#else
20
29
finalcurrent:Map<String, T>;
21
-
30
+
#end
22
31
/**
23
32
* The assets that were previously cached. May be re-cached, but if not, they will be purged.
24
33
*/
34
+
#if FEATURE_MULTITHREADING
35
+
finalprevious:SynchronizedMap<String, T>;
36
+
#else
25
37
finalprevious:Map<String, T>;
38
+
#end
26
39
27
40
/**
28
41
* An FlxSignal which is dispatched when an asset is removed. Typically used for cleanup of assets that need to be manually destroyed (e.g. FlxGraphics).
@@ -48,9 +61,15 @@ class StagedCache<T> implements IStagedCache
48
61
{
49
62
// The cache maps are final to prevent them from being overridden,
50
63
// but they are still mutable.
64
+
#if FEATURE_MULTITHREADING
65
+
permanent=SynchronizedMap.newStringMap();
66
+
current=SynchronizedMap.newStringMap();
67
+
previous=SynchronizedMap.newStringMap();
68
+
#else
51
69
permanent= [];
52
70
current= [];
53
71
previous= [];
72
+
#end
54
73
}
55
74
56
75
/**
@@ -188,9 +207,16 @@ class StagedCache<T> implements IStagedCache
0 commit comments