-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Move Non Send Resources into thread locals #5135
Conversation
82da848
to
247f2b1
Compare
We're already using |
This appears to be complementary to #3519, correct? |
This works very differently despite the similar name. Quoting from the crate:
There is also the issue that
Yeah. I'll add it to the description |
fb5f1ef
to
0d9c5e8
Compare
0d9c5e8
to
d366917
Compare
Objective
Fix problem with world being send and dropping non send resources on the wrong thread.
Alternative to #3519,
Solution
thread_local_object
crate to move non send resources into thread local memory. This means that trying to access the non send resource off the thread that spawned it will end up with the resource not being found.thread_local_object
drops the objects it keeps when the thread is dropped instead of when it's instance is dropped.Advantages
Disadvantages
world.remove_non_send_resource
vs removing the resource from the ThreadLocalResource,ThreadLocalResouce::remove
.thread_local_object
are not dropped when theThreadLocalResource
is dropped. They are only dropped when the thread is dropped orThreadLocalResource;:remove
is called on the corrent thread. I added an explicit drop for the thread thatThreadLocalResource
is dropped on, but this doesn't help if the world has been sent. So this is a potential memory leak.Migration Guide
// TODO
ToDo