diff options
Diffstat (limited to 'source/modules/asura-utils/io/data_buffer.cpp')
-rw-r--r-- | source/modules/asura-utils/io/data_buffer.cpp | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/source/modules/asura-utils/io/data_buffer.cpp b/source/modules/asura-utils/io/data_buffer.cpp index 36e13c7..37f749c 100644 --- a/source/modules/asura-utils/io/data_buffer.cpp +++ b/source/modules/asura-utils/io/data_buffer.cpp @@ -10,15 +10,15 @@ namespace AsuraEngine { DataBuffer::DataBuffer(DataBuffer& src) - : mSize(0) - , mCapacity(0) - , mBytes(nullptr) + : m_Size(0) + , m_Capacity(0) + , m_Bytes(nullptr) { // ʼ - lock(mMutex) + lock(m_Mutex) { - mCapacity = src.mSize; - mBytes = new byte[mCapacity]; + m_Capacity = src.m_Size; + m_Bytes = new byte[m_Capacity]; Clear(); Load(src); @@ -26,27 +26,27 @@ namespace AsuraEngine } DataBuffer::DataBuffer(std::size_t capacity) - : mSize(0) - , mCapacity(0) - , mBytes(nullptr) + : m_Size(0) + , m_Capacity(0) + , m_Bytes(nullptr) { - lock(mMutex) + lock(m_Mutex) { - mCapacity = capacity; - mBytes = new byte[mCapacity]; + m_Capacity = capacity; + m_Bytes = new byte[m_Capacity]; Clear(); } } DataBuffer::DataBuffer(const void* data, std::size_t size) - : mCapacity(0) - , mSize(0) - , mBytes(nullptr) + : m_Capacity(0) + , m_Size(0) + , m_Bytes(nullptr) { - lock(mMutex) + lock(m_Mutex) { - mCapacity = size; - mBytes = new byte[mCapacity]; + m_Capacity = size; + m_Bytes = new byte[m_Capacity]; Clear(); Load(data, size); @@ -55,23 +55,23 @@ namespace AsuraEngine DataBuffer::~DataBuffer() { - lock(mMutex) + lock(m_Mutex) { - delete[] mBytes; + delete[] m_Bytes; } } void DataBuffer::Refactor(size_t capacity) { - lock(mMutex) + lock(m_Mutex) { - if (!mBytes || mCapacity != capacity) + if (!m_Bytes || m_Capacity != capacity) { - if(mBytes) - delete[] mBytes; - mCapacity = capacity; - mBytes = new byte[mCapacity]; - mSize = 0; + if(m_Bytes) + delete[] m_Bytes; + m_Capacity = capacity; + m_Bytes = new byte[m_Capacity]; + m_Size = 0; } Clear(); } @@ -79,7 +79,7 @@ namespace AsuraEngine void DataBuffer::Load(DataBuffer& db) { - lock(mMutex) + lock(m_Mutex) { Load(db.GetData(), db.GetSize()); } @@ -87,69 +87,69 @@ namespace AsuraEngine void DataBuffer::Load(const void* data, std::size_t size) { - lock(mMutex) + lock(m_Mutex) { - ASSERT(mCapacity >= size); - memcpy(mBytes, data, size); - mSize = size; + ASSERT(m_Capacity >= size); + memcpy(m_Bytes, data, size); + m_Size = size; } } void DataBuffer::Move(void* bytes, std::size_t size) { - lock(mMutex) + lock(m_Mutex) { - if (mBytes == bytes) + if (m_Bytes == bytes) { // sizeֵڶļʱ - mSize = size; + m_Size = size; } else { - if (mBytes) - delete[] mBytes; - mBytes = (byte*)bytes; - mSize = size; - mCapacity = size; + if (m_Bytes) + delete[] m_Bytes; + m_Bytes = (byte*)bytes; + m_Size = size; + m_Capacity = size; } } } byte* DataBuffer::GetData() { - return mBytes; + return m_Bytes; } void DataBuffer::Clear() { - lock(mMutex) + lock(m_Mutex) { - if (mBytes) + if (m_Bytes) { - memset(mBytes, 0, mSize); - mSize = 0; + memset(m_Bytes, 0, m_Size); + m_Size = 0; } } } std::size_t DataBuffer::GetSize() { - return mSize; + return m_Size; } std::size_t DataBuffer::GetCapacity() { - return mCapacity; + return m_Capacity; } void DataBuffer::Lock() { - mMutex.Lock(); + m_Mutex.Lock(); } void DataBuffer::Unlock() { - mMutex.Unlock(); + m_Mutex.Unlock(); } } |