3 ms·
If you only want to hold the lock for a portion of a function, pull that part out into its own function. Makes the code much easier to reason about. I consider
by physicles 6y ago
If you only want to hold the lock for a portion of a function, pull that part out into its own function. Makes the code much easier to reason about. I consider .Unlock() without defer to be a code smell in nearly all cases.