Skip to content

Commit 3cdcce4

Browse files
1.2.14 Multicomponents store improvements
1 parent 59cc4c7 commit 3cdcce4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Src/MultiComponent/MultiComponent.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
using System.Collections.Generic;
1010
using System.Diagnostics.CodeAnalysis;
1111
using System.Runtime.CompilerServices;
12-
using System.Runtime.InteropServices;
13-
using System.Threading;
1412
using static System.Runtime.CompilerServices.MethodImplOptions;
1513
#if ENABLE_IL2CPP
1614
using Unity.IL2CPP.CompilerServices;
@@ -703,7 +701,7 @@ public void Dispose() {
703701
#endif
704702
public class MultiComponents<T> where T : struct {
705703
#if FFS_ECS_DEBUG
706-
private readonly HashSet<uint> _blocked = new();
704+
private readonly System.Collections.Concurrent.ConcurrentDictionary<uint, bool> _blocked = new();
707705
internal MultiThreadStatus mtStatus;
708706
#endif
709707

@@ -817,17 +815,17 @@ internal static byte SlotCapacityToLevel(uint capacity) {
817815
#if FFS_ECS_DEBUG
818816
[MethodImpl(AggressiveInlining)]
819817
internal bool IsBlocked(ref Multi<T> value) {
820-
return _blocked.Contains(Level.PackSlot(value.blockIdx, value.dataOffset));
818+
return _blocked.ContainsKey(Level.PackSlot(value.blockIdx, value.dataOffset));
821819
}
822820

823821
[MethodImpl(AggressiveInlining)]
824822
internal void Block(uint blockIdx, byte offset) {
825-
_blocked.Add(Level.PackSlot(blockIdx, offset));
823+
_blocked[Level.PackSlot(blockIdx, offset)] = true;
826824
}
827825

828826
[MethodImpl(AggressiveInlining)]
829827
internal void Unblock(uint blockIdx, byte offset) {
830-
_blocked.Remove(Level.PackSlot(blockIdx, offset));
828+
_blocked.TryRemove(Level.PackSlot(blockIdx, offset), out _);
831829
}
832830
#endif
833831
}

0 commit comments

Comments
 (0)