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

Values inserted into State::pub_sub HashMap are never removed, leaky. #63

Open
cheako opened this issue Sep 26, 2020 · 0 comments
Open

Comments

@cheako
Copy link

cheako commented Sep 26, 2020

e.insert(tx);

I'm working on my own project and find it hard to implement a pub_sub system that isn't either manually managing memory(an anti-rust patter IMHO) or forgetting about it altogether as this code does.

Edit/Replace:
I wrote what maybe a working solution:
https://gitlab.com/cheako/websuite-rs/-/blob/21e9c2e7e2bb31dd0e3f94cc5ae23a17ece8e2c0/naomi/src/lib.rs
I didn't use a mpsc for the locking here, because I didn't want to be sending messages in a Drop handler... What do you think?

I'm playing with some ideas, but nothing is working out:
tov/weak-table-rs#5
https://gitlab.com/cheako/websuite-rs/-/blob/77258e059853acf9b678049c8016d3545394d2f6/naomi/src/lib.rs#L69
https://gitlab.com/cheako/websuite-rs/-/blob/af387566968a48bb8a8cb574d1baf30eb953d141/naomi/src/lib.rs#L138

Another project struggling with this is feather a minecraft server:
https://github.com/feather-rs/feather/blob/e6927044246e258cd0529645429ae83b45a23628/server/chunk/src/chunk_manager.rs#L84

As such, solutions welcome.

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