The cleanest way I've seen of using a sentry is to always explicitly start a block, 'i.e. {' right before constructing the sentry and then explicitly end the block when the lock ends. The code above appears to have the lock in the correct place but it would be easier to follow if it were explicit.