[*] Improved AuByteBuffer structure

This commit is contained in:
Reece Wilson 2024-03-17 13:57:28 +00:00
parent a7033c40e2
commit bcb007ebe8
2 changed files with 36 additions and 22 deletions

View File

@ -8,6 +8,7 @@
#pragma once
#include <Aurora/Locale/ECodePage.hpp>
#include <Aurora/Utility/PrivData.hpp>
namespace Aurora::Memory
{
@ -44,10 +45,16 @@ namespace Aurora::Memory
*/
struct ByteBuffer
{
///////////////////////////////////////////////////////////////////////
// User storage: //
///////////////////////////////////////////////////////////////////////
AURT_ADD_USR_DATA;
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Stable ByteBuffer ABI Header; length and read/write head pointers //
///////////////////////////////////////////////////////////////////////
/// Internal capacity to mitigate trivial reallocs
AuUInt allocSize;
@ -56,32 +63,38 @@ namespace Aurora::Memory
/// Buffer pointer
AuUInt8 *base {};
/// Stream pointer
/// Read stream pointer
AuUInt8 *readPtr {};
/// Stream pointer
/// Write stream pointer
AuUInt8 *writePtr {};
///////////////////////////////////////////////////////////////////////
// Stable ByteBuffer ABI Header; u32 flags //
///////////////////////////////////////////////////////////////////////
/// Is ring buffer?
AuUInt8 flagCircular : 1 {};
/// Should resize linear buffer to accommodate additional writes
AuUInt8 flagExpandable : 1 {};
AuUInt8 flagReadError : 1 {};
AuUInt8 flagWriteError : 1 {};
AuUInt8 flagNoFree : 1 {};
AuUInt8 flagNoRealloc: 1 {};
AuUInt8 flagAlwaysExpandable : 1 {};
// TODO: flag: allow circular overrun to allow for 100% access of the buffer from either read head
// - implicit padding
AuUInt8 scaleSize {};//
AuUInt8 alignment {};
///////////////////////////////////////////////////////////////////////
// Memory protection
// (resize/free/etc fails when this value is not zero. free-during-use protection)
///////////////////////////////////////////////////////////////////////
AuAUInt32 uInUseCounter { 0 };
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Stable ByteBuffer ABI Header; u8 flags //
///////////////////////////////////////////////////////////////////////
AuUInt8 flagCircular : 1 {}; /// Is ring buffer?
AuUInt8 flagExpandable : 1 {}; /// Should resize linear buffer to accommodate additional writes
AuUInt8 flagReadError : 1 {}; /// Has error? Has read error?
AuUInt8 flagWriteError : 1 {}; /// Has error? Has write error?
AuUInt8 flagNoFree : 1 {}; /// Prevents all free operations
AuUInt8 flagNoRealloc : 1 {}; /// Prevents a subset of free options, specifically realloc, operations
AuUInt8 flagAlwaysExpandable : 1 {}; /// Internal flag. Do not use.
AuUInt8 flagReserveA : 1 {}; /// Placeholder
///////////////////////////////////////////////////////////////////////
// Special flags/values
///////////////////////////////////////////////////////////////////////
AuUInt8 alignment {}; // Internal value: keeps track of explicit Allocate of alignment values
AuUInt8 scaleSize {}; // TODO:
///////////////////////////////////////////////////////////////////////
/**
* @brief Move constructor
* @param buffer

View File

@ -94,7 +94,8 @@ namespace Aurora::Utility
inline void PrivateUserDataClear()\
{\
AuResetMember(this->_auReservedUserData.pData);\
}
}\
public:
#define AURT_ADD_USR_DATA_EXP(exp) \
inline virtual AURT_PRIVATE_DATA_PTR PrivateUserDataGet()\