pixelherodev commented on PR #578:
URL: https://github.com/apache/arrow-go/pull/578#issuecomment-3573675481
I'm just going to write up the design notes as one place to explain all the
weirdness:
- Looking over the existing code for Message/MessageReader, there's a few
requirements:
- Buffers get released when the last reference to them is erased.
- When buffers get released, we also nil out the pointer to them.
- When 1 object is released, we want to walk every object it references
and release those too.
- This is often done by _value at the time of Release_, not when the
object is created, and includes a "if != nil" check. The object may not be
created until _after the object is initialized_, if ever, and should be
released regardless. e.g. `MessageReader.msg` is a `*Message`, and has a
different value for each Message that is read.
So, in trying to _separate_ the concerns of reference counting and object
management, and trying to make it all declarative and only called on object
initialization - keeping the refcount graph _static_, even as the objects in it
may be dynamic! - I settled on using two-level-pointers. The address of
`MessageReader.msg` is fixed, even as its value may change - we want to release
whatever the _final value is_ when MessageReader gets released, and we don't
want to insert a lot more code dynamically shifting around the reference graph.
--
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]