[+] AuMemory::SharableByteBuffer

This commit is contained in:
Reece Wilson 2024-02-25 23:37:24 +00:00
parent 42af66c841
commit 2731183a1a

View File

@ -635,4 +635,50 @@ namespace Aurora::Memory
this->memory = pRAIIParentOwner;
}
};
struct SharableByteBuffer : ByteBuffer,
AuEnableSharedFromThis<SharableByteBuffer>
{
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<MemoryViewWrite> ToSharedWriteView()
{
this->writeView = *this;
return { this->SharedFromThis(), &this->writeView };
}
inline AuSPtr<MemoryViewRead> ToSharedReadView()
{
this->readView = *this;
return { this->SharedFromThis(), &this->readView };
}
inline operator AuSPtr<MemoryViewWrite>()
{
return this->ToSharedWriteView();
}
inline operator AuSPtr<MemoryViewRead>()
{
return this->ToSharedReadView();
}
};
}