-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Can the fluid world protected by a arc mutex be shared between threads? #6
Comments
|
Sharing between threads is done using the |
Actually, sharing between threads is done by
If |
True, not at the same time, but you could wrap it in an |
That's true, because |
I'm testing nphysics, salva and legion (entity component system) together. I need all the physics data to be a legion resource (and that it means that it will be shared between threads). The problem is with the LiquidWorld that is non Send, so I can not included inside the physics bundle resource. If I wrap everything with a Arc<Mutex<>> like the following code:
Then I can mark it as Send using an "unsafe" impl (like the above). Is this really safe or there is some hidden problems that will arise?
unsafe impl Send for PhysicsResource {}
EDIT: Not even the unsafe impl makes it compile. The important part of the error messages goes like:
Edit 2: If I change on the salva source "liquid_world.rs" (the two lines above), I can compile (without the unsafe impl). But I'm not sure if it ok or I'm missing something. Above the changes I made:
On the LiquidWorld struct definition add + Send to the solve:
solver: Box<dyn PressureSolver<N> + Send>,
And also add + Send to the new function:
solver: impl PressureSolver<N> + 'static + Send,
The text was updated successfully, but these errors were encountered: