diff options
| author | Stefan Boberg <[email protected]> | 2021-05-13 12:14:56 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-13 12:14:56 +0200 |
| commit | 18985cd6d3703f63fb8d307ca771396981883a10 (patch) | |
| tree | 8ad53a95c86ceb625fbfe959eadb0d4a8c80dcfd /zencore/include | |
| parent | Made SharedBuffer/UniqueBuffer share guts with IoBuffer (diff) | |
| download | zen-18985cd6d3703f63fb8d307ca771396981883a10.tar.xz zen-18985cd6d3703f63fb8d307ca771396981883a10.zip | |
CbWriter::Save now returns an immutable payload buffer
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/sharedbuffer.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/zencore/include/zencore/sharedbuffer.h b/zencore/include/zencore/sharedbuffer.h index 093f43231..7f9c61adb 100644 --- a/zencore/include/zencore/sharedbuffer.h +++ b/zencore/include/zencore/sharedbuffer.h @@ -22,8 +22,8 @@ class UniqueBuffer public: UniqueBuffer(const UniqueBuffer&) = delete; UniqueBuffer& operator=(const UniqueBuffer&) = delete; + UniqueBuffer() = delete; - UniqueBuffer() = default; ZENCORE_API explicit UniqueBuffer(IoBufferCore* Owner); void* GetData() { return m_Buffer->MutableDataPointer(); } @@ -42,6 +42,7 @@ public: ZENCORE_API static UniqueBuffer MakeMutableView(void* DataPtr, uint64_t Size); private: + // This may never be null RefPtr<IoBufferCore> m_Buffer; friend class SharedBuffer; @@ -76,6 +77,12 @@ public: return 0; } + inline void MakeImmutable() + { + ZEN_ASSERT(m_Buffer); + m_Buffer->SetIsImmutable(true); + } + ZENCORE_API void MakeOwned(); bool IsOwned() const { return m_Buffer && m_Buffer->IsOwned(); } inline explicit operator bool() const { return m_Buffer; } @@ -109,8 +116,8 @@ public: /** Make a non-owned view of the input */ ZENCORE_API static SharedBuffer MakeView(const void* Data, uint64_t Size); /** Make a non-owned view of the input */ - ZENCORE_API static SharedBuffer MakeView(MemoryView View, SharedBuffer Buffer); - /** Make am owned clone of the buffer */ + ZENCORE_API static SharedBuffer MakeView(MemoryView View, SharedBuffer OuterBuffer); + /** Make an owned clone of the buffer */ ZENCORE_API SharedBuffer Clone(); /** Make an owned clone of the memory in the input view */ ZENCORE_API static SharedBuffer Clone(MemoryView View); |