|
|
|
|
|
by akling
1174 days ago
|
|
After sketching this out, it's nice that this: auto x = state.with([](auto& state) { return state.x; });
Becomes this: auto x = state.locked()->x;
But it also creates this very accessible footgun: auto& x = state.locked()->x;
Where it's way too easy to bind a reference to something that should be protected by the lock, but now isn't. So I'm not sure this is a great idea anymore. |
|
At least the synchronized pattern makes it easy to document which state is protected by which mutex.