| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
- builderPattern
- Functional Programming
- compose
- PrototypePattern
- ㅋㅁ
- designPattern
- 추상팩토리패턴
- 코루틴
- 옵저버 패턴
- factory method
- Abstract Factory
- 디자인패턴
- 코틀린멀티플랫폼
- 팩토리 메소드
- 함수형프로그래밍
- Kotlin
- material3
- kmp
- 코틀린
- 디자인패턴 #
- 추상 팩토리
- android designsystem
- Design Pattern
- 빌터패턴
- 프로토타입 패턴
- 안드로이드 디자인시스템
- kotlin multiplatform
- Coroutines
- Observer Pattern
- define
- Today
- Total
목록Coroutine (37)
오늘도 더 나은 코드를 작성하였습니까?
디스패처를 이용해 코루틴이 실행되어야 할 스레드 또는 스레드풀 결정할수 있다.어떤 스레드에서 실행될지 정하는것은 코루틴 컨텍스트이다.기본 디스패처 Dispatcher.Default- 설정하지 않으면, 기본적으로 설정됨.- CPU집약적인 연산을 하도록 설계- 코드가 실행되는 컴퓨터의 CPU 개수와 동일한 수의 스레드풀을 가진다.suspend fun main(): Unit = coroutineScope { repeat(1000) { launch { List(1000) { Random.nextLong() }.maxOrNull() val threadName = Thread.currentThread().name println("Run o..
코루틴 스코프 함수스코프를 만드는 다양한 함수가 있습니다.coroutineScope supervisorScope - Job대신 SupervisorJob사용 withContext - 컨텍스트를 변경withTimeoutScope - 실행시간 존재 이러한 스코프 함수들은 스코프를 만들기 위해 사용된다. 코루틴 빌더 vs 코루틴 스코프 함수코루틴 빌더코루틴 스코프 함수launch, async, producecoroutineScope, supervisorScope, withContext,withTimeoutScopeCoroutineScope의 확장 함수중단함수CoroutineScope의 리시버 코루틴 컨텍스트 사용중단함수의 컨티뉴에이션 객체의 코루틴 컨텍스트사용예외는 Job을 통해 부모로 전파됨일반함수와 같은 방..
여러개의 엔드포인트에서 동시에 데이터를 얻어야하는 중단함수.suspend fun getUserProfile(): UserProfileData { val user = getUserData() val notifications = getNotifications() return UserProfileData( user = user, notifications = notifications )} 동시에 사용자 데이터와 노티정보를 가져오려면 async{ ... } 빌더를 이용해야 한다.async => Coroutinescope를 필요로 한다. 1. GlobalScope (하면안됨)suspend fun getUserProfile(): UserProfileData { ..
잡히지 않은 예외가 발생하면, 프로그램이 종료하듯 코루틴도 잡히지 않은 예외가 발생했을때 종료합니다.코루틴 빌더는 부모도 종료시키며, 취소된 부모는 자식들 모두를 취소시킨다.import kotlinx.coroutines.delayimport kotlinx.coroutines.launchimport kotlinx.coroutines.runBlockingfun main(): Unit = runBlocking { launch { launch { delay(1000) throw Error("some error") } launch { delay(2000) println("Will not be ..
