Hacker News new | ask | show | jobs
by franke2 1168 days ago
Even if very similar, I prefer the MutexedObj class described in those two articles

https://fekir.info/post/extend-generic-thread-safe-mutexed_o...

https://fekir.info/post/sharing-data-between-threads/#_bind-...

In particular it explains why providing getters or operator* like some other implementation do (not in this case) is not a feature, and it does not use multiple classes (like the linked implementation of SerenityOS does) making the implementation simpler.

Also the "simple" implementation is just 20 lines of code...