3 ms·
I always felt that pattern was a bit too clever than it was a good design.
by saagarjha 2y ago
I always felt that pattern was a bit too clever than it was a good design.
- karmarepellent 2y agoMakes me wonder what part of the pattern you think is "too clever"? I think it is fairly easy to reason about when the lock is restricted to the encompassing block and automatically dropped when you leave the block.
- saagarjha 2y agoIt’s kind of a weird design that some of your variables (which you can define anywhere in the scope FWIW) just randomly define a critical section. I strongly prefer languages that do a with lock { // do stuff } design. This could be C++ too to be honest because lambdas exist but RAII is just too common for people to design their locks like this.