What is the best method for setting up a variable wait time in a coroutine?

There’s a point in a coroutine where I have the typical

yield return new WaitForSeconds(variableTime);

but if something happens in the meantime, I would like to force the coroutine to stop waiting and move on to the next step. I’ve been thinking of doing a while loop, checking if a boolean has changed and how much time has passed, but not sure if this is the most efficient way if I can instead just change the variableTime to 0 and/or just have it move on instead of checking for more.

float timePassed = 0;
while (YourCondition != true & timePassed < YourDelay)
{
timePassed+=Time.deltaTime;
yield return new WaitForEndOfFrame();
}

should work, i think