Geon

Modern Concurrency Deep Dive(5) 본문

iOS developer essential skills/Modern Concurency

Modern Concurrency Deep Dive(5)

jgkim1008 2024. 11. 18. 23:45

Continuation

- 동기 코드를 비동기 코드로 연결해주는 매커니즘

- 콜백 방식의 api, delegate 방식의 api를 async/await 방식으로 전환가능

- 반드시 한번만 호출해야함(호출을 안해도 누수 발생할수 있다.)

// 런타임에 체크 (안전성)
// Continuation의 잘못된 사용이나 에러 플래그를 감지하여 오류 나타냄
await withCheckedContinuation
try await withCheckedThrowingContinuation


// 런타임에 체크 하지 않음
// 퍼포먼스 중요할떄
await withUnsafeContinuation
try await awitWithUnSafeThrowingContinuation