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

Support for owner #5

Open
pauxus opened this issue May 26, 2017 · 0 comments
Open

Support for owner #5

pauxus opened this issue May 26, 2017 · 0 comments

Comments

@pauxus
Copy link
Member

pauxus commented May 26, 2017

if A contains B and B holds an owner reference to A, the owner reference (B'.owner) should point to the containing instance of A' instead of creating a new one.

There are several options:

  • Always use factories (A'.create) instead of constructor calls. This would allow some kind of caching of instances. Problem: this would be global, what about when you explicitly want different wrapper instances on the same delegate (for changeable wrappers)?
  • Using some kind of ThreadLocal: When the first constructor of a Wrapper is called, a mapper is initialized. All Wrappers are registered there and the factory checks whether the delegate has already been wrapped, if yes, the wrapped instance is returned. Problem: what if the same instance is used in different contexts? (Corner case) - Also, this might mean that KlumWrap must be available at runtime (instead of compile time only), since we need a place to store this ThreadLocal)
  • A Wrapper instance keeps references to all its direct wrapper children in a structure. When an inner wrapper ist instantiated, it is provided with its container as additional parameter. Whenever the child creates a wrapped instance, it is checked first against the container instance. This would mean rather complex logic
  • KlumWrap could have a direct depedency to KlumAST and handle the owner annotation as a special case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant