> But with judicious appropriate comments, all should be well, and your chances
of leaving the function’s scope without releasing the lock are zero.
True, but consider the scenario when you may have to release the lock and subsequently re-acquire it
in some cases. Apparently, you must be able to find a workaround by messing around with scopes and loops, but imagine how ugly it is going to look. As long as you to things in C-like fashion and treat a spinlock as a variable, rather than an object, you task is just straightforward
Anton Bassov