Geon

Modern Concurrency Deep Dive(17) 본문

iOS developer essential skills/Modern Concurency

Modern Concurrency Deep Dive(17)

jgkim1008 2024. 12. 10. 01:06

암시적 취소 전파

func getImage() asnyc throws -> [UIImage] {
 var array: [UIImage] = []
 async let image1 = fetchImage()
 async let image2 = fetchImage()
 asnyc let iamge3 = fetchImage()
 
  // 빨리 끝나는 작업을 먼저 하는게 좋음
  // image1에서 오류가나면 나머지 비동기 작업은 취소 image2까지는 작업이 될 확률이 높음
  // 가장 에러가 발생하기 쉬운?? 작업을 앞 쪽에 배치 필요
 let image1 = try await image1
 let iamge2 = try await image2
 let image3 = try await image3
 
 array.append(image1,image2,image3)



}

- 외부에서 취소가 아닌 내부에서 오류로 인해 취소되었을떄, 부모에서 내부적으로 전파하는것을 암시적 취소 전파라고 할수 있다.

- 외부에서 취소는 명시적 취소 전파라 할수 있다.