JibbSmart / JoyShockLibrary

Read DualSense, DualShock 4, JoyCon, and Pro Controller input on PC -- compiled for Windows, but code should work on other platforms.
Other
226 stars 42 forks source link

Make read-lock for callbacks exception-safe with RAII shared_lock wrapper #52

Closed gordonglas closed 1 year ago

gordonglas commented 1 year ago

If the user's callback functions throw an exception, the shared read-lock will never unlock, and create a deadlock if the callbacks are attempted to be updated afterwords. This is easily solved with C++14's std::shared_lock wrapper that uses RAII to automatically call unlock_shared when it goes out of scope.