Arbitrary locking mechanism for asynchronous operations