From 2731183a1a603d8ef6d728934bf9c8abb34f5b1a Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sun, 25 Feb 2024 23:37:24 +0000 Subject: [PATCH] [+] AuMemory::SharableByteBuffer --- Include/Aurora/Memory/ByteBuffer.hpp | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Include/Aurora/Memory/ByteBuffer.hpp b/Include/Aurora/Memory/ByteBuffer.hpp index ee3f25cb..6f1f783d 100644 --- a/Include/Aurora/Memory/ByteBuffer.hpp +++ b/Include/Aurora/Memory/ByteBuffer.hpp @@ -635,4 +635,50 @@ namespace Aurora::Memory this->memory = pRAIIParentOwner; } }; + + struct SharableByteBuffer : ByteBuffer, + AuEnableSharedFromThis + { + SharableByteBuffer() : ByteBuffer() + { + + } + + SharableByteBuffer(AuUInt uLength, bool circular = false, bool expandable = false) : ByteBuffer(uLength, circular, expandable) + { + + } + + SharableByteBuffer(AuUInt uLength, AuUInt uAlignment, bool circular = false, bool expandable = false) : ByteBuffer(uLength, uAlignment, circular, expandable) + { + + } + + private: + MemoryViewRead readView; + MemoryViewWrite writeView; + + public: + inline AuSPtr ToSharedWriteView() + { + this->writeView = *this; + return { this->SharedFromThis(), &this->writeView }; + } + + inline AuSPtr ToSharedReadView() + { + this->readView = *this; + return { this->SharedFromThis(), &this->readView }; + } + + inline operator AuSPtr() + { + return this->ToSharedWriteView(); + } + + inline operator AuSPtr() + { + return this->ToSharedReadView(); + } + }; } \ No newline at end of file