jvanstraten commented on a change in pull request #12116:
URL: https://github.com/apache/arrow/pull/12116#discussion_r806151531



##########
File path: cpp/src/arrow/memory_pool.cc
##########
@@ -536,6 +543,39 @@ int64_t MemoryPool::max_memory() const { return -1; }
 // MemoryPool implementation that delegates its core duty
 // to an Allocator class.
 
+class ImmutableZeros : public Buffer {
+ public:
+  explicit ImmutableZeros(uint8_t* data, int64_t size, MemoryPool* pool)
+      : Buffer(data, size, CPUDevice::immutable_zeros_memory_manager(pool)),
+        pool_(pool) {}
+
+  ImmutableZeros() : Buffer(nullptr, 0), pool_(nullptr) {}
+
+  ~ImmutableZeros() override;
+
+  // Prevent copies and handle moves explicitly to avoid double free

Review comment:
       I'm not sure why or what you mean by that? It's analogous to 
`PoolBuffer` in that it uses RAII to free memory when it is no longer needed, 
except two `Buffer` classes are needed to correctly model shared ownership, 
i.e. `ImmutableZeros` models the data, `ImmutableZerosPoolBuffer` models a 
shared reference to that data (even in contexts where a `unique_ptr` or raw 
pointer/reference to a `Buffer` is needed). Writing it down like this though, 
the names could use some refactoring, especially now that they both implement 
`Buffer`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to