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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user