HebiRobotics / HebiCam

MATLAB utility for streaming video acquisition (h264, mjpeg, etc.)
Other
12 stars 5 forks source link

Simplify locking code #7

Open ennerf opened 5 years ago

ennerf commented 5 years ago

There is quite a bit of error handling code required by the fact that users may ctrl+c when copying an image, which causes the user lock to never be released. This is tough to understand and prone to errors.

In other projects I've switched to using a wrapping handle class that implements RAII (lock in constructors, unlock in destructor), which can guarantee that the lock is always released once it's out of scope, i.e., when exiting the getsnapshot function (for any reason). HebiCam should switch over as well.