Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

NativeParallelMultiHashMapTests_JobDebugger.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using NUnit.Framework;
  2. using System;
  3. using Unity.Jobs;
  4. using Unity.Collections;
  5. using Unity.Collections.Tests;
  6. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  7. internal class NativeParallelMultiHashMapTests_JobDebugger : NativeParallelMultiHashMapTestsFixture
  8. {
  9. [Test]
  10. public void NativeParallelMultiHashMap_Read_And_Write_Without_Fences()
  11. {
  12. var hashMap = new NativeParallelMultiHashMap<int, int>(hashMapSize, CommonRwdAllocator.Handle);
  13. var writeStatus = CollectionHelper.CreateNativeArray<int>(hashMapSize, CommonRwdAllocator.Handle);
  14. var readValues = CollectionHelper.CreateNativeArray<int>(hashMapSize, CommonRwdAllocator.Handle);
  15. var writeData = new MultiHashMapWriteParallelForJob()
  16. {
  17. hashMap = hashMap.AsParallelWriter(),
  18. status = writeStatus,
  19. keyMod = hashMapSize,
  20. };
  21. var readData = new MultiHashMapReadParallelForJob()
  22. {
  23. hashMap = hashMap,
  24. values = readValues,
  25. keyMod = writeData.keyMod,
  26. };
  27. var writeJob = writeData.Schedule(hashMapSize, 1);
  28. Assert.Throws<InvalidOperationException>(() => { readData.Schedule(hashMapSize, 1); });
  29. writeJob.Complete();
  30. hashMap.Dispose();
  31. writeStatus.Dispose();
  32. readValues.Dispose();
  33. }
  34. struct NestedMapJob : IJob
  35. {
  36. public NativeParallelMultiHashMap<int, NativeParallelMultiHashMap<int, int>> nestedMap;
  37. public void Execute()
  38. {
  39. nestedMap.Clear();
  40. }
  41. }
  42. [Test]
  43. public void NativeParallelMultiHashMap_NestedJob_Error()
  44. {
  45. var map = new NativeParallelMultiHashMap<int, NativeParallelMultiHashMap<int, int>>(hashMapSize, CommonRwdAllocator.Handle);
  46. var nestedJob = new NestedMapJob
  47. {
  48. nestedMap = map
  49. };
  50. JobHandle job = default;
  51. Assert.Throws<InvalidOperationException>(() => { job = nestedJob.Schedule(); });
  52. job.Complete();
  53. map.Dispose();
  54. }
  55. }
  56. #endif