From 30256c77a5e790881815f180472e47e9e84f3225 Mon Sep 17 00:00:00 2001 From: Chikashi Miyama Date: Sat, 6 Jul 2019 16:22:52 +0200 Subject: [PATCH] add PdBuffer --- .gitignore | 1 + .../Assets/Scripts/PdConnection/PdBuffer.cs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .gitignore create mode 100644 UnityProject/Assets/Scripts/PdConnection/PdBuffer.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dee35da --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +UnityProject/Library diff --git a/UnityProject/Assets/Scripts/PdConnection/PdBuffer.cs b/UnityProject/Assets/Scripts/PdConnection/PdBuffer.cs new file mode 100644 index 0000000..9abf421 --- /dev/null +++ b/UnityProject/Assets/Scripts/PdConnection/PdBuffer.cs @@ -0,0 +1,24 @@ +using System; +using System.IO.MemoryMappedFiles; + +namespace PdConnection +{ + public class PdBuffer : IDisposable + { + private readonly MemoryMappedFile memoryMappedFile_; + private readonly MemoryMappedViewAccessor viewAccessor_; + + public PdBuffer() + { + memoryMappedFile_ = MemoryMappedFile.OpenExisting("shared_memory"); + viewAccessor_ = memoryMappedFile_.CreateViewAccessor(); + } + + public void Dispose() + { + viewAccessor_?.Dispose(); + memoryMappedFile_?.Dispose(); + } + } + +}