김누누
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] 코루틴 스코프 만들기

💡 안드로이드와 백엔드에서 코루틴 스코프를 어떻게 만들고 활용하는지 학습하였습니다.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
[Coroutine] Job과 Child 코루틴

[Coroutine] Job과 Child 코루틴

💡 구조화된 동시성에 이어서 Job과 child 코루틴의 특징에 대하여 학습하였습니다.Coroutine Job?Job은 코루틴을 취소하고, 상태를 파악하는 등 다양하게 사용될 수 있는 컨텍스트입니다.수명주기를 가지며 인터페이스 입니다.구체적인 사용법과 상태를 가지고 있다는 점에서 추상 클래스처럼 다룰 수 있습니다.Coroutine Job 상태 도식도아래와 같이 6가지 상태와 도식표로 나타낼 수 있습니다.실제 코드에서는 toString을 활용해 잡의 상태를 볼 수 있습니다.Active잡이 실행되고 코루틴이 잡을 수행합니다.잡이 코루틴 빌더에 의해 생성되었을 때, 본체가 실행되는 상태이며 자식 코루틴을 시작할 수 있습니다.New대부분 코루틴은 Active 상태로 시작되지만, 지연 시작되는 코루틴은 New ..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 7. 25.
  • textsms
[Coroutine] 코루틴 컨텍스트

[Coroutine] 코루틴 컨텍스트

💡 코루틴 빌더에서 활용되는 코루틴 컨텍스트에 대하여 학습하였습니다.코루틴 컨텍스트코루틴 빌더의 정의를 보면 첫 번째 파라미터가 CoroutineContext임을 알 수 있습니다.fun CoroutineScope.launch( context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job리시버뿐만 아니라 마지막 인자의 리시버도 CoroutineScope 타입이며, 중요한 개념으로 활용되는 CoroutineContext의 정의를 알아야 합니다 !CoroutineContext 인터페이스Corou..

  • format_list_bulleted Deep Dive/Kotlin Coroutine
  • · 2024. 7. 23.
  • textsms
  • navigate_before
  • 1
  • 2
  • 3
  • 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)
전체 방문자
오늘
어제
전체
태그
  • #ViewModel
  • #compose
  • #Coroutine
  • #코루틴
  • #코틀린
  • #우테코
  • #Android
  • #알고리즘
  • #kotlin
  • #안드로이드
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바