Community

swift — 드디어 오버헤드 없이 안전한 Continuation이 생겼어요!

기존에는 UnsafeContinuation(빠르지만 위험)과 CheckedContinuation(안전하지만 allocation+atomic 오버헤드) 사이에서 선택을 강요받았어요. double-resume은 undefined behavior, missing-resume은 silent hang이라는 치명적인 문제도 있었고요. SE-0528은 ~Copyable struct인 Continuation를 도입해 이 문제를 해결합니다. double-resume은 move-only semantics + consuming 메서드로 컴파일 에러, missing-resume은 deinit 트랩으로 런타임 크래시로 잡아줘요. 오버헤드는 UnsafeContinuation과 동일하게 없습니다. withContinuation(of: T.self, throwing: E.self) 함수는 SE-0413 typed throws를 활용해 non-throwing / typed throwing / untyped throwing 세 가지를 하나로 통합했고, 기존 CheckedContinuation은 deprecated 없이 멀티 콜백 상황을 위해 계속 유지돼요. Swift 타입 시스템으로 콜백 브리징의 고질적 버그를 완전히 해결한 우아한 변경입니다 🙌 https://green1229.tistory.com/622

알림

알림이 없습니다