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 long-lived values that are not bound to &Env (GlobalValue) #8

Open
ubolonton opened this issue Apr 22, 2019 · 1 comment
Open

Comments

@ubolonton
Copy link
Owner

ubolonton commented Apr 22, 2019

  • Module code can store values for later use, e.g. in background threads.
  • Frequently-used symbols won't require repeated intern calls into the Lisp runtime. We can have emacs::sym::nil, emacs::sym::t. Modules will also be able to declare symbols they often use.
  • Error handling will not need unsafe (even though the safety requirement is almost trivial currently).

The biggest problem with this is that free_global_ref() requires an emacs_env, thus cannot be used directly in GlobalValue::drop() (this is likely a mis-design in emacs-module (BEAM's enif_release_resource doesn't need an env, for example)). There are 2 potential ways to solve this:

  • Add fn free(self, env: &Env), and just leak on normal drops. They are supposed to be long-lived anyway.
  • Add a "mini-GC" by globally tracking to-be-free values, and freeing them in Env::drop(), once in a while.
@ubolonton
Copy link
Owner Author

This was added in release 0.13.0, but has not been stabilized/documented yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant