Why not just replace `@hash` with a new instance that is empty here?

It would allow you to release the lock and process the old one outside of the lock.