Skip to content

기본적인 코루틴 빌더 및 디스패처 #22

Merged
sh1mj1 merged 3 commits intodevfrom
kotlin/coroutine/basic
May 6, 2025
Merged

기본적인 코루틴 빌더 및 디스패처 #22
sh1mj1 merged 3 commits intodevfrom
kotlin/coroutine/basic

Conversation

@sh1mj1
Copy link
Owner

@sh1mj1 sh1mj1 commented May 6, 2025

본격적인 코루틴 학습 테스트에 앞서, 기본 개념 및 동작 방식 숙지 목적의 테스트 코드 작성

  1. 코루틴 빌더에 대한 테스트 작성
  • runBlocking: 메인 스레드를 블로킹하며 테스트 실행
  • launch: Job 객체를 반환하고 비동기 실행, join()으로 완료 대기
  • async: Deferred 객체를 반환하고 비동기 실행, await()로 결과 수집
  • CoroutineName: 각 코루틴에 이름 부여 및 context 활용 확인
  1. 코루틴 디스패처에 대한 테스트 작성
  • newFixedThreadPoolContext: 데몬 스레드를 사용하는 Executor 기반 디스패처 확인
  • 자식 코루틴은 별도 설정이 없으면 부모 디스패처를 상속하는 구조
  • Dispatchers.Default, Dispatchers.IO, limitedParallelism 사용 사례 확인
  • 스레드 풀 공유 여부 및 데몬 여부 등 디버깅

Next Feature

코루틴 빌더 launch 와 Job

sh1mj1 added 2 commits May 6, 2025 14:09
CoroutineDispatcher: 코루틴을 스레드로 보내거나 실행을 위해 대기열에 추가하는 코루틴 관리자

- newFixedThreadPoolContext
- 부모 코루틴과 자식 코루틴 구조
- Dispatchers.Default, Dispatchers.IO, limitedParallelism
@sh1mj1 sh1mj1 requested a review from Copilot May 6, 2025 05:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a set of coroutine tests to verify the behavior of various coroutine builders (runBlocking, launch, async) and dispatchers in Kotlin, ensuring that coroutine names, delay handling, and thread usage conform to expected patterns.

  • Added tests for coroutine builders and their returned objects.
  • Tested CoroutineName usage and behavior of various CoroutineDispatchers including newFixedThreadPoolContext and Dispatchers with limitedParallelism.
  • Verified thread daemon properties and shared thread pool behaviors.

Deferred가 Job의 하위 타입임을 명확히 하기 위해 테스트 설명을 업데이트하고 이를 확인하는 assert 문을 추가
@sh1mj1 sh1mj1 merged commit 6487761 into dev May 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants