rust-sfml icon indicating copy to clipboard operation
rust-sfml copied to clipboard

[Question] `Send` for Texture

Open woubuc opened this issue 7 years ago • 4 comments
trafficstars

I'm running into an issue when loading textures from a thread, that Texture isn't Send. Is this on purpose or is it possible to make it Send?

woubuc avatar Oct 07 '18 14:10 woubuc

I'm not sure what can be Send and what cannot. See #179.

I personally think probably Texture cannot be Send, because it has to remain on the same thread as the OpenGL context, but maybe Image can be Send, where you could load an Image from a separate thread, and then create a Texture from it on the main thread.

crumblingstatue avatar Oct 07 '18 15:10 crumblingstatue

Thanks for the answer. Is this something you're looking into or are you looking for others to take this on?

Also, I've tried manually making Texture Send and it seemed to move from my loader thread to my main thread just fine. I'm not sure it's safe that way though, I'm not very familiar with these things yet.

woubuc avatar Oct 13 '18 07:10 woubuc

A sensible course of action would be to discuss this with the SFML maintainers. They should know more about the thread safety of various SFML types. If you'd like to, you could have a talk with them about the types you are interested in making Send, and report here.

crumblingstatue avatar Oct 13 '18 11:10 crumblingstatue

Not sure about whether this makes any difference, but there's AtomicPtr that can help enforcing atomicity on owned pointer (and they are owned, at least in case of SfBox)

vaartis avatar Dec 31 '19 10:12 vaartis