Using boost sync, scope-exit, etc.