Merge "Extract out common busy wait function" into main