Add checked shared-buffer span operations

Use `SharedBuffer<int>` across the reader and writer apps, with callback-based buffer access. Add bounds checks to array and span read/write operations.
This commit is contained in:
Matthias Heil
2026-11-19 10:16:51 +01:00
parent a42b3393d4
commit 2ce631940d
4 changed files with 60 additions and 24 deletions
+8 -6
View File
@@ -1,12 +1,14 @@
using SharedMemory;
try
{
using var numbers = new SharedArray<int>("MySharedArray");
Console.WriteLine(numbers.Length);
Console.WriteLine(numbers[0]);
Console.WriteLine(numbers[^1]);
using var consumer = new WriterApp.SharedBuffer<int>("MySharedBuffer");
consumer.BufferAction((span) =>
{
for (var i = 0; i < span.Length; i++)
{
Console.WriteLine($"Read {span[i]} from the shared buffer");
}
});
}
catch (FileNotFoundException)
{