//var threadCount = 8; //var map = new ConcurrentSlotMap(); //var barrier = new Barrier(threadCount); //Parallel.For(0, threadCount, threadIndex => //{ // barrier.SignalAndWait(); // for (var i = 0; i < 1000; i++) // { // var id = map.Add(i + threadIndex * 1000, out var gen); // if (i % 100 == 0) // { // map.Remove(id, gen); // } // } //}); //Console.WriteLine($"Count should be {threadCount * 990}, actual: {map.Count}"); using Misaki.HighPerformance.LowLevel; BenchmarkDotNet.Running.BenchmarkRunner.Run(); //using Misaki.HighPerformance.LowLevel.Buffer; //using Misaki.HighPerformance.LowLevel.Collections; //using Misaki.HighPerformance.LowLevel.Utilities; //using (AllocationManager.CreateStackScope()) //{ // var array = new UnsafeArray(10, Allocator.Stack); // for (var i = 0; i < array.Count; i++) // { // array[i] = i; // } // foreach (var item in array.AsSpan()) // { // Console.WriteLine(item); // } //} //var arr1 = new Misaki.HighPerformance.LowLevel.Collections.UnsafeArray(10, Misaki.HighPerformance.LowLevel.Buffer.Allocator.Persistent); //var arr2 = arr1; //arr1.Dispose(); //try //{ // arr2[0] = 42; // This should throw an exception because arr1 has been disposed. //} //catch (Exception ex) //{ // Console.WriteLine($"Caught expected exception: {ex.Message}"); //} //arr2.Dispose(); // This should not cause a double free error because of safe handle. var a = new UniquePtr(); unsafe { var b = a.Share(); b.Get()->Value = 42; } internal struct MyStruct { public int Value; }