Hacker News new | ask | show | jobs
by zeroonetwothree 4510 days ago
folly::Synchronized implements this in a correct way (and also prevents access without acquiring the lock):

SYNCHRONIZED(data) { // modify data }

https://github.com/facebook/folly/blob/master/folly/Synchron...