Geon

Modern Concurrency Deep Dive(12) 본문

iOS developer essential skills/Modern Concurency

Modern Concurrency Deep Dive(12)

jgkim1008 2024. 11. 25. 23:34

작업 취소

- Task 내부에, Task 구현시 취소를 전파하지 못함

- try? await 은 nil 을 리턴하여 취소시에 에러를 리턴하지 않고 바로 다음줄 실행

- Task.checkCancellation() 은 취소에 대한 에러를 리턴해줌

var task = Task {
 print("시작")



  Task {
   await someFunction()
   await someFunction()
   await someFunction()
   print(Task.isCancelled) // false


  }
 }
 sleep(3)
 task.cancel()