김누누
close
프로필 배경
프로필 로고

김누누

  • 분류 전체보기 (252)
    • Deep Dive (49)
      • Kotlin Coroutine (18)
      • Kotlin Flow (6)
      • Test Code (12)
      • Android Jetpack Compose (9)
      • Flutter (4)
    • [Android] Architecture (14)
      • Architecture Pattern (5)
      • [Android] Multi Module (3)
      • [Android] DI (4)
    • [Kotlin] Tech,Study (18)
    • [Android] Tech,Study (65)
      • [Android] Trouble Shoot (20)
      • [Android] Custom (9)
    • Algorithm (13)
    • Computer Science (29)
      • 독서 (8)
      • 프로그래밍 (14)
      • 운영체제 (4)
      • 자료구조 (1)
      • 네트워크 (1)
    • GitHub (1)
    • Python,Django,DRF (13)
    • IOS,Swift (10)
    • 회고 (7)
  • 깃허브
  • 글쓰기
  • 설정
[Coroutine] 코틀린 코루틴 테스트

[Coroutine] 코틀린 코루틴 테스트

💡 코틀린 코루틴에서 테스트하는 방법에 대하여 학습하였습니다. 코틀린 코투린 테스트대부분의 경우 중단 함수를 테스트하는 것은 일반적인 함수를 테스트하는 것과 다르지 않습니다.class FetchUserUseCase( private val repo: UserDataRepository) { suspend fun fetchUserData(): User = coroutineScope { val name = async { repo.getName() } val friends = ascycn { repo.getFriends() } val profile async { repo.getProfile() } User( name = name.a..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 8. 24.
  • textsms
[Coroutine] 공유 상태로 인한 문제

[Coroutine] 공유 상태로 인한 문제

💡 코루틴에서 발생할 수 있는 공유 상태로 인한 문제를 확인하고, 이를 동기화 블로킹을 통해 어떻게 해결할 수 있는지 학습하였습니다. 공유 상태로 인한 문제class UserDowloader( private val api : NetworkService) { private val users = mutableListOf() fun downloaded(): List = users.toList() suspend fun fetchUser(id: Int) { val newUser = api.fetchUser(id) users.add(newUser) }}위 코드는 동시 사용에 대한 대비가 되어 있지 않습니다.fetchUser 호출은 users를 변경하는데, 이 경..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 8. 16.
  • textsms
[Coroutine] 코루틴 스코프 만들기

[Coroutine] 코루틴 스코프 만들기

💡 안드로이드와 백엔드에서 코루틴 스코프를 어떻게 만들고 활용하는지 학습하였습니다.CoroutineScope 팩토리 함수CoroutineScope는 coroutineContext를 유일한 프로퍼티로 가지고 있는 인터페이스입니다.interface CoroutineScope { val coroutineContext: CoroutineContext}CoroutineScope 객체 생성CoroutineScope 인터페이스를 구현한 클래스를 만들고 내부에서 코루틴 빌더를 직접 호출할 수 있지만, 이 방법은 문제가 있습니다.cancel이나 ensureActivce 같은 메서드를 직접 호출하면 문제가 발생함갑자기 전체 스코프를 취소하면 코루틴이 더 이상 시작될 수 없음class SomeClass : Corou..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 8. 16.
  • textsms
[Coroutine] 코루틴 디스패처

[Coroutine] 코루틴 디스패처

💡 RxJava에서의 스케줄러와 비슷한 기능을 하는 코루틴 디스패처에 대하여 학습하였습니다. CoroutineDispatcher코투린 디스패처는 코루틴을 스레드로 보내는 역할을 합니다.모든 작업은 스레드 위에서 실행돼야 하고, 코루틴 또한 작입이므로 스레드 위에서만 실행될 수 있습니다.우리가 코루틴을 만들어 CoroutineDispatcher로 코루틴 실행을 요청하면, CoroutineDispatcher는 자신이 사용할 수 있는 스레드풀의 스레드 중 하나에 코루틴을 보냅니다.기본 디스패처디스패처를 설정하지 않으면 기본적으로 Dispatchers.Default가 설정됩니다.CPU를 많이 사용하는 작업에서 실행합니다.이 디스패처는 코드가 실행되는 컴퓨터의 CPU 개수와 동일한 수(최소 2개 이상)의 스레드..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 7. 27.
  • textsms
[Coroutine] 코루틴 스코프 함수

[Coroutine] 코루틴 스코프 함수

💡 코루틴의 생명 주기를 제어하는 데 도움을 주는 코루틴 스코프 함수에 대하여 학습하였습니다.코루틴 스코프코루틴 스코프의 필요성아래 작업은 중단 함수에서 중단 함수를 호출하며, 작업이 동시에 진행되지 않는다는 문제가 있습니다.하나의 앤드포인트에서 데이터를 얻는 데 1초씩 걸리므로 총 2초 소모suspend fun getUserProfile() : UserProfileData { val user = getUserData() // 1초 후 val notifications = getNotifications() // 1초 후 return UserProfileData( user = user, notifications = notifications, )}두 중단 함수..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 7. 27.
  • textsms
[Coroutine] 코루틴 예외 처리

[Coroutine] 코루틴 예외 처리

💡 코루틴의 작동 원리 중 아주 중요한 기능인 코루틴 예외 처리에 대하여 학습하였습니다.예외 처리잡히지 않는 예외가 발생하면 프로그램이 종료되는 것처럼, 코루틴도 잡히지 않은 예외가 발생했을 때 종료됩니다.큰 차이는 코루틴 빌더는 부모도 종료시키며, 취소된 부모는 자식들 모두를 취소시킵니다.fun main(): Unit = runBlocking { launch { launch { delay(1000) throw Error("Error") } launch { delay(2000) println("Will not be printed") } launch { ..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 7. 26.
  • textsms
  • navigate_before
  • 1
  • 2
  • navigate_next
전체 카테고리
  • 분류 전체보기 (252)
    • Deep Dive (49)
      • Kotlin Coroutine (18)
      • Kotlin Flow (6)
      • Test Code (12)
      • Android Jetpack Compose (9)
      • Flutter (4)
    • [Android] Architecture (14)
      • Architecture Pattern (5)
      • [Android] Multi Module (3)
      • [Android] DI (4)
    • [Kotlin] Tech,Study (18)
    • [Android] Tech,Study (65)
      • [Android] Trouble Shoot (20)
      • [Android] Custom (9)
    • Algorithm (13)
    • Computer Science (29)
      • 독서 (8)
      • 프로그래밍 (14)
      • 운영체제 (4)
      • 자료구조 (1)
      • 네트워크 (1)
    • GitHub (1)
    • Python,Django,DRF (13)
    • IOS,Swift (10)
    • 회고 (7)
전체 방문자
오늘
어제
전체
태그
  • #Android
  • #kotlin
  • #코루틴
  • #알고리즘
  • #compose
  • #Coroutine
  • #우테코
  • #ViewModel
  • #안드로이드
  • #코틀린
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바