Ideally acquire/release patterns should be scoped, i.e. the calls should occur in the same scope. Currently the lock is acquire in a function that has nothing to do with locking.