2 ms·
> so in A and B you do lock(_mutex) but in C you do assert_lock(_mutex) which either panics or continues? What would that look like? What's wrong with doing ex
by archagon 4y ago
> so in A and B you do lock(_mutex) but in C you do assert_lock(_mutex) which either panics or continues? What would that look like?
What's wrong with doing exactly what you said? If somebody ends up misusing C_UnderLock, their program will crash, and they can go fix their bug.
- alkonaut 4y agoI’m wondering if there is such a primitive like assert_lock() or similar, which will let me do that.
- archagon 4y agoApple has one for `os_unfair_lock`: https://developer.apple.com/documentation/os/2976314-os_unfair_lock_assert_owner https://developer.apple.com/documentation/os/2976314-os_unfa...
- alkonaut 4y agoLooks like if (!Monitor.IsEntered(_x)) throw new InvalidOperation. Will do the trick in C#