Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.6KB

  1. // using System.Threading.Tasks;
  2. // using NUnit.Framework;
  3. // using Svelto.Common;
  4. // using Svelto.ECS.DataStructures;
  5. //
  6. // namespace Svelto.ECS.Tests.Common.DataStructures
  7. // {
  8. // [TestFixture]
  9. // public class ThreadSafeNativeBagTest
  10. // {
  11. // [Test]
  12. // public void TestByteReallocWorks()
  13. // {
  14. // var threadNativeBag = new ThreadSafeNativeBag(Allocator.Persistent);
  15. //
  16. // Parallel.Invoke(() =>
  17. // {
  18. // for (int i = 0; i < 100; i++)
  19. // {
  20. // threadNativeBag.Enqueue((int)1);
  21. // }
  22. // }
  23. // , // close first Action
  24. // () =>
  25. // {
  26. // for (int i = 0; i < 100; i++)
  27. // {
  28. // threadNativeBag.Enqueue((int)2);
  29. // }
  30. // }
  31. // , //close second Action
  32. //
  33. // () =>
  34. // {
  35. // for (int i = 0; i < 100; i++)
  36. // {
  37. // threadNativeBag.Enqueue(3);
  38. // }
  39. // } //close third Action
  40. // ); //close parallel.invoke
  41. //
  42. // // for (int i = 0; i < 100; i++)
  43. // // {
  44. // // threadNativeBag.Enqueue(1);
  45. // // }
  46. //
  47. // int oneCount = 0, twoCount = 0, threeCount = 0;
  48. //
  49. // while (threadNativeBag.count > 0)
  50. // {
  51. // var value = threadNativeBag.Dequeue<int>();
  52. //
  53. // switch (value)
  54. // {
  55. // case 1:
  56. // oneCount++;
  57. // break;
  58. // case 2:
  59. // twoCount++;
  60. // break;
  61. // case 3:
  62. // threeCount++;
  63. // break;
  64. // }
  65. // }
  66. //
  67. // Assert.That(oneCount, Is.EqualTo(100));
  68. // Assert.That(twoCount, Is.EqualTo(100));
  69. // Assert.That(threeCount, Is.EqualTo(100));
  70. //
  71. // threadNativeBag.Dispose();
  72. // }
  73. // }
  74. // }