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

Add StaticSendable base class that can be owned by the registry #7713

Open
virtuald opened this issue Jan 19, 2025 · 1 comment
Open

Add StaticSendable base class that can be owned by the registry #7713

virtuald opened this issue Jan 19, 2025 · 1 comment

Comments

@virtuald
Copy link
Member

It would be nice if instead of a static variable, there was a mechanism to create a shared_ptr that is owned by the SendableRegistry (making it effectively a singleton) by name somehow. This would allow PRs like #7712 to not leak memory.

I'm not convinced this is a great idea, but I'd like to remove as many static globals as we can from the library for 2027, as it would make unit testing using a clean slate easier, and also simplify things for robotpy.

@PeterJohnson
Copy link
Member

PeterJohnson commented Jan 20, 2025

I don't think it's realistic to remove static globals. They make the library more user friendly, as it avoids the need for users to keep around random variables. If we want to improve global cleanup of static variables, I think a better solution would be to import and use LLVM's ManagedStatic (https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/ManagedStatic.h) anywhere where we currently use a magic or global static. We'd probably have to change the shutdown function to be thread-safe, but it's close to what we need. We should also probably write an equivalent of it for Java?

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

2 participants