I'd suggest using the `synchronized<...>` template from `helpers/synchronized.h` here.