> We are guaranteed to already have the lock if this runs

This code locks the queue (the "giant" lock) and immediately checks if the task in question is currently locked and running. So the rest of the method can safely assume that to be the case.