Change condition wait to use value capture instead of ref.