zeroshade commented on code in PR #578:
URL: https://github.com/apache/arrow-go/pull/578#discussion_r2558108594


##########
arrow/memory/refcount.go:
##########
@@ -0,0 +1,75 @@
+//go:build !norc
+
+package memory
+
+import (
+       "sync/atomic"
+       "unsafe"
+
+       "github.com/apache/arrow-go/v18/arrow/internal/debug"
+)
+
+type Refcount struct {
+       count        atomic.Int64
+       dependencies []unsafe.Pointer
+       buffers      []**Buffer
+       derived      []unsafe.Pointer
+}
+
+// Must only be called once per object. Defines the dependency tree.
+// When this object is completely unreferenced, all dependencies will
+// be unreferenced by it and, if this was the only object still
+// referencing them, they will be freed as well, recursively.
+func (r *Refcount) ReferenceDependency(d ...unsafe.Pointer) {
+       r.dependencies = d
+}
+
+// Must only be called once per object. Defines buffers that are referenced
+// by this object. When this object is unreferenced, all such buffers will
+// be deallocated immediately.
+func (r *Refcount) ReferenceBuffer(b ...**Buffer) {
+       r.buffers = b
+}

Review Comment:
   you mean "When this object is cleaned up" or "released"? Because Go is 
garbage collected and we don't have destructors, then just being `unreferenced` 
won't deallocate the buffers immediately, they'll get deallocated when the GC 
gets around to it



-- 
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