WuhuIslandTesting/Library/PackageCache/com.unity.collections@1.2.4/Unity.Collections.Tests/NativeMultiHashMapTests_JobDebugger.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2025-01-07 02:06:59 +01:00
using NUnit.Framework;
using System;
using Unity.Jobs;
using Unity.Collections;
using Unity.Collections.Tests;
#if ENABLE_UNITY_COLLECTIONS_CHECKS
internal class NativeMultiHashMapTests_JobDebugger : NativeMultiHashMapTestsFixture
{
[Test]
public void NativeMultiHashMap_Read_And_Write_Without_Fences()
{
var hashMap = new NativeMultiHashMap<int, int>(hashMapSize, CommonRwdAllocator.Handle);
var writeStatus = CollectionHelper.CreateNativeArray<int>(hashMapSize, CommonRwdAllocator.Handle);
var readValues = CollectionHelper.CreateNativeArray<int>(hashMapSize, CommonRwdAllocator.Handle);
var writeData = new MultiHashMapWriteParallelForJob()
{
hashMap = hashMap.AsParallelWriter(),
status = writeStatus,
keyMod = hashMapSize,
};
var readData = new MultiHashMapReadParallelForJob()
{
hashMap = hashMap,
values = readValues,
keyMod = writeData.keyMod,
};
var writeJob = writeData.Schedule(hashMapSize, 1);
Assert.Throws<InvalidOperationException>(() => { readData.Schedule(hashMapSize, 1); });
writeJob.Complete();
hashMap.Dispose();
writeStatus.Dispose();
readValues.Dispose();
}
}
#endif