반응형
Async
-
async-awaitBackEnd/coroutine 2025. 6. 8. 05:00
async와 Deferredasync 코루틴 빌더를 호출하면 코루틴이 생성되고, Deferred 타입 객체가 반환됩니다.Deferred는 Job과 같이 코루틴을 추상화한 객체이지만, 코루틴으로부터 생성된 결과값을 감싸는 기능을 추가로 가집니다.결과값의 타입은 제네릭 타입인 T로 표현됩니다.public fun CoroutineScope.async( context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): Deferred async vs launchasync 함수도 launch 함수와 마찬가지로cont..