Skip to content

Commit e746fee

Browse files
committed
CacheFile2: add uid mutex in Ast.Tools
1 parent 310bfa6 commit e746fee

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hxsl/Ast.hx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ typedef ShaderData = {
350350
class Tools {
351351

352352
static var UID = 0;
353+
#if heaps_mt_hxsl_cache
354+
static var uidMutex = new sys.thread.Mutex();
355+
#end
353356

354357
public static var SWIZ = Component.createAll();
355358
public static var MAX_CHANNELS_BITS = 3;
@@ -361,7 +364,14 @@ class Tools {
361364
#if macro
362365
return --UID;
363366
#else
364-
return ++UID;
367+
#if heaps_mt_hxsl_cache
368+
uidMutex.acquire();
369+
#end
370+
var id = ++UID;
371+
#if heaps_mt_hxsl_cache
372+
uidMutex.release();
373+
#end
374+
return id;
365375
#end
366376
}
367377

0 commit comments

Comments
 (0)