Coroutine 학습 with 공식문서 번역

조갱·2022년 3월 20일
0

Coroutine

목록 보기
1/9

배정받은 파트에서 사용되는 코드는 전부다 Coroutine이 적용되어있다.

suspend fun ~~~~

거의 모든 메소드가 suspend fun 구문으로 되어있는데, 이해가 잘 안된다.
질문을 했지만, 여전히 잘 모르겠다!

그러다가 한 선임분께서 공식 문서 정독을 추천해주셔서, 시작하게 된 Coroutine 학습 With 공식문서 번역!

공식 문서를 정독하면 얻을 이득? 에 대해 생각해봤다.

  • 좀더 꼼꼼하게 배울 수 있다.
    (일단 영어를 번역해야하니까.. 뭐든 1번씩은 읽게됨)
  • 놓친 부분 없이 세세하게 배울 수 있다.
    (블로그 등 검색을 통해 공부하다보면 놓치는 부분도 있다.)
  • 영어 실력 향상..?

아무튼 시작!
(잘못된 지식이나 오역이 있을 경우 알려주시면 감사하겠습니다!)

공식 문서 링크 : https://kotlinlang.org/docs/coroutines-guide.html

내가 직접 실습하는 깃허브 링크 : https://github.com/KyungHyun-Cho/Coroutine-Ex


Coroutine 가이드

마지막 수정일: 2021-08-26

한국어

(언어로써의) 코틀린은 표준 라이브러리를 통해 최소한의 low-level API만을 제공하기 때문에 다양한 라이브러리가 coroutine을 사용할 수 있도록 한다.

비슷한 성능을 가진 다른 많은 언어들과는 다르게, asyncawait는 코틀린 키워드가 아니며, 표준 라이브러리의 일부분도 아니다.

게다가, 코틀린의 suspending function의 컨셉은 비동기 동작을 위해 퓨처프로미스 보다 더 안전하고 에러 가능성이 적은 추상적 개념을 제공한다.

kotlinx.coroutines 은 JetBrains 에 의해 개발된 코루틴을 위한 풍부한 라이브러리이다.

이 가이드는 launch, async 등을 포함하여 coroutine에서 사용할 수 있는 많은 high-level primitives를 포함한다.

이 가이드는 kotlinx.coroutines의 주요 기능에 대한 가이드로, 예시들과 여러 토픽들로 구성되어 있다.

coroutine을 사용하고, 예제를 따라하기 위해서는 project ReadMe (클릭)에 설명되어있는 kotlinx-coroutines-core dependency를 추가해야한다.

원문

Kotlin, as a language, provides only minimal low-level APIs in its standard library to enable various other libraries to utilize coroutines.

Unlike many other languages with similar capabilities, async and await are not keywords in Kotlin and are not even part of its standard library.

Moreover, Kotlin's concept of suspending function provides a safer and less error-prone abstraction for asynchronous operations than futures and promises.

kotlinx.coroutines is a rich library for coroutines developed by JetBrains.

It contains a number of high-level coroutine-enabled primitives that this guide covers, including launch, async and others.

This is a guide on core features of kotlinx.coroutines with a series of examples, divided up into different topics.

In order to use coroutines as well as follow the examples in this guide, you need to add a dependency on the kotlinx-coroutines-core module as explained in the project README.


(아래 부분은 번역하는대로 링크 같이 추가할 예정!)

Table of contents

Coroutines basics - Coroutine 기초
Hands-on: Intro to coroutines and channels
Cancellation and timeouts
Composing suspending functions
Coroutine context and dispatchers
Asynchronous Flow
Channels
Coroutine exceptions handling
Shared mutable state and concurrency
Select expression (experimental)
Tutorial: Debug coroutines using IntelliJ IDEA
Tutorial: Debug Kotlin Flow using IntelliJ IDEA

Additional references

Guide to UI programming with coroutines
Coroutines design document (KEEP)
Full kotlinx.coroutines API reference
Best practices for coroutines in Android
Additional Android resources for Kotlin coroutines and flow

참고하면 좋은
퓨처와 프로미스 : https://ko.wikipedia.org/wiki/%ED%93%A8%EC%B2%98%EC%99%80_%ED%94%84%EB%A1%9C%EB%AF%B8%EC%8A%A4

profile
A fast learner.

0개의 댓글