aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-20 23:38:04 +0200
committerStefan Boberg <[email protected]>2026-04-20 23:38:04 +0200
commit56b485d7d291950a4edff1d25e8594dca891c0ce (patch)
treeaf63ceafea1ac77a4a5d5a0b6e238d4cc76f3137 /src/zenstore/include
parentUse eastl::deque for queues with many small elements (#991) (diff)
downloadarchived-zen-sb/fix-batch-ptr.tar.xz
archived-zen-sb/fix-batch-ptr.zip
structured cache: return unique_ptr from Create*Batch factoriessb/fix-batch-ptr
- ZenCacheNamespace::CreatePutBatch/CreateGetBatch now return std::unique_ptr so ownership is explicit at the call site - ZenCacheNamespace::PutBatchHandle/GetBatchHandle own their disk-layer handle and clean it up in the destructor, so the public DeletePutBatch/DeleteGetBatch entry points on ZenCacheNamespace are removed - ZenCacheStore::PutBatch/GetBatch store the handle as unique_ptr and their destructors collapse to `= default`; the try/catch wrappers are no longer needed since destruction is driven by the destructors of types that do not throw - Disk-layer public API (CreatePutBatch, DeletePutBatch, etc.) is untouched because its inner batch-handle structs live in the .cpp and exposing them to the header to satisfy std::unique_ptr's completeness requirement would leak implementation details
Diffstat (limited to 'src/zenstore/include')
-rw-r--r--src/zenstore/include/zenstore/cache/structuredcachestore.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/zenstore/include/zenstore/cache/structuredcachestore.h b/src/zenstore/include/zenstore/cache/structuredcachestore.h
index 3722a0d31..16be04ace 100644
--- a/src/zenstore/include/zenstore/cache/structuredcachestore.h
+++ b/src/zenstore/include/zenstore/cache/structuredcachestore.h
@@ -85,14 +85,12 @@ public:
~ZenCacheNamespace();
struct PutBatchHandle;
- PutBatchHandle* CreatePutBatch(ZenCachePutResultVec_t& OutResults);
- void CommitPutBatch(PutBatchHandle* Batch);
- void DeletePutBatch(PutBatchHandle* Batch) noexcept;
+ std::unique_ptr<PutBatchHandle> CreatePutBatch(ZenCachePutResultVec_t& OutResults);
+ void CommitPutBatch(PutBatchHandle* Batch);
struct GetBatchHandle;
- GetBatchHandle* CreateGetBatch(ZenCacheValueVec_t& OutResults);
- void CommitGetBatch(GetBatchHandle* Batch);
- void DeleteGetBatch(GetBatchHandle* Batch) noexcept;
+ std::unique_ptr<GetBatchHandle> CreateGetBatch(ZenCacheValueVec_t& OutResults);
+ void CommitGetBatch(GetBatchHandle* Batch);
bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
void Get(std::string_view Bucket, const IoHash& HashKey, GetBatchHandle& OptionalBatchHandle);
@@ -217,9 +215,9 @@ public:
~PutBatch();
private:
- ZenCacheStore& m_CacheStore;
- ZenCacheNamespace* m_Store = nullptr;
- ZenCacheNamespace::PutBatchHandle* m_NamespaceBatchHandle = nullptr;
+ ZenCacheStore& m_CacheStore;
+ ZenCacheNamespace* m_Store = nullptr;
+ std::unique_ptr<ZenCacheNamespace::PutBatchHandle> m_NamespaceBatchHandle;
friend class ZenCacheStore;
};
@@ -232,10 +230,10 @@ public:
~GetBatch();
private:
- ZenCacheStore& m_CacheStore;
- ZenCacheNamespace* m_Store = nullptr;
- ZenCacheNamespace::GetBatchHandle* m_NamespaceBatchHandle = nullptr;
- ZenCacheValueVec_t& Results;
+ ZenCacheStore& m_CacheStore;
+ ZenCacheNamespace* m_Store = nullptr;
+ std::unique_ptr<ZenCacheNamespace::GetBatchHandle> m_NamespaceBatchHandle;
+ ZenCacheValueVec_t& Results;
friend class ZenCacheStore;
};