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
Do we still need SDL_LockJoysticks() in the public API? #6956
Comments
I removed it, but then I remembered that people might want to lock around getting the list of joysticks and then querying attributes about them. I don't feel strongly either way, but it seems like it's still useful. |
My thinking is that if they query an instance that has vanished (or is bogus), we should return an error and they should ignore that device. It's probably not useful to provide correct information for a device that is no longer available. |
Fair enough. I’ll remove it from the public API. |
All joystick functions are thread-safe and you can now get an atomic list of joysticks with SDL_GetJoysticks() Fixes libsdl-org#6956
All joystick functions are thread-safe and you can now get an atomic list of joysticks with SDL_GetJoysticks() Fixes #6956
Yes, we still need the functions to lock joystick mappings. |
In SDL3, SDL_GetJoysticks() returns a copy of the list to the app, which means they don't need to protect against the list changing while they iterate it.
We probably need to maintain a mutex internally, but does it make sense to make this lock public, especially if it's going to touch not just the list but the delivery of events?
It's trivial for an app to provide its own lock if they deal with the array returned by SDL_GetJoysticks() from multiple threads, but I assume most things won't be touching it from multiple threads in the first place.
The text was updated successfully, but these errors were encountered: