Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider api for releasing or taking ownership of data in a node #69

Closed
cyrush opened this issue Oct 13, 2016 · 2 comments
Closed

consider api for releasing or taking ownership of data in a node #69

cyrush opened this issue Oct 13, 2016 · 2 comments
Labels

Comments

@cyrush
Copy link
Member

cyrush commented Oct 13, 2016

converting from external to owned, and vice versa.

We tried to attack this before, had a hard time with finding the right names.

@cyrush cyrush added the feature label Oct 13, 2016
@cyrush cyrush added this to the 0.2.2 milestone Apr 26, 2017
@cyrush
Copy link
Member Author

cyrush commented May 30, 2017

@xjrc @bryujin

Pondering this a bit more. It's tricky:

Node n;
n["a/b/c/d/e/f"].set_int32(10);
n["a/b/c/d/e/g"].set_int32(11);

// in n f + g own data
 
Node n2;
n.compact_to(n2);

// in n2 root owns data
int32 *f_ptr = n2["a/b/c/d/e/f"].element_ptr()
int32 *g_ptr = n2["a/b/c/d/e/g"].element_ptr()

// these would be no-ops, which is fine:
n2["a/b/c/d/e/f"].release_ownership();
n2["a/b/c/d/e/g"].release_ownership();

// however:
Node n3;
n3["f"].set_external(f_ptr);
n3["g"].set_external(g_ptr);

// this would be very dangerous:
n3["f"].take_ownership();
n3["g"].take_ownership();






@cyrush cyrush removed this from the 0.3.0 milestone May 30, 2017
@cyrush
Copy link
Member Author

cyrush commented Aug 7, 2020

we have pondered this quite a bit -- don't think there is a safe way to provide this.
If someone asks again, we can revisit -- but for many use cases it hasn't come up.

@cyrush cyrush closed this as completed Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant