Skip to content
Beside the Wheel
Search
Ctrl
K
Cancel
Email
GitHub
Select theme
Dark
Light
Auto
공부
(5)
spot 인스턴스에서 서버 가용성 개선하기
eBPF로 서버 성능 Profiling하는 법: Pyroscope의 구현 살펴보기
정수론부터 RSA까지
strace로 shaka-packager 버그 추적
Kubernetes The Hard Way
TIL
(937)
AI
(43)
DevOps
(230)
Network
(61)
OS
(155)
개발
(113)
과학
(1)
데이터베이스
(64)
서버
(72)
수학
(20)
알고리즘
(24)
암호학
(32)
언어
(95)
컴퓨터구조
(3)
코드
(24)
독후감
(43)
과학
(1)
사회
(2)
산문
(3)
소설
(12)
인문
(11)
자기계발
(7)
철학
(7)
생각
(6)
고민
변화에 대하여
의식의 영역에 대하여
본질을 보려면
짧은 생각들
소유냐 존재냐
회고
(13)
2022.03-04 대덕소마고 입학소감/다짐
2022.05-08 프로젝트와 인간관계
2022.09-2023.02 불안과 판단
2023.03-07 DMS 리더 회고
2023.08-11 나는 누구인가?
2023.12 더 많은 걸 배우기 위한 경험
2024.01-02 회사 인턴 회고
2024.03-04 3학년으로서 근황
2024.05-07 나름 알찬 3학년
2024.08-12 첫 회사
2025.01-03 입출력
2025.03-08 효능감이란 무엇일까
2025.09-12 연말회고
Email
GitHub
Select theme
Dark
Light
Auto
태그: coroutine
총 8개의 글이 있습니다.
Channel
coroutine
2024. 3. 13.
Channel은 2개의 Coroutine 사이를 연결한 파이프라고 생각하면 된다. 이 파이프는 두 Coroutine 사이에서 정보를 전송할 수 있도록 한다. 하나의 Coroutine은 파이프를 통해서 정보를 보낼 수 있고, 다른 하나의 Coroutine은 정보를 받기위해 기다린다. 이 채널을 통한 두 Coroutine간의 커뮤니케이션은 공유메모리가 아닌, 커뮤니케이션을 통해서 이뤄진다. Thread는 어떻게 Communicate 할까 소프트웨어를 만들면서 Resource를 Blocking하는 작업, 예를 들면 네트워킹이나 DB를 사용하거나 아니면 계산이 필요한 작업을 할때 우리는 그 작업들을 쓰레드로 분리한다. 이 쓰레드간에 공유할 자원이 필요할때 우리는 두개의 쓰레드가 동시에 그걸 쓰거나 읽게
Coroutine CPS
coroutine
2024. 3. 13.
Kotlin coroutines are managed at the JVM level using the concept of "continuations." Continuations are a programming technique that allows suspending the execution of a function at a certain point and resuming it later from where it left off. Coroutines build upon this concept to provide a high-level and efficient way to write asynchronous code. Continuation When a code with suspend is conv
Coroutine Delay
coroutine
2024. 3. 13.
아래와 같은 timeout(혹은 delay)가 내부적으로 어떻게 동작하는지 알아보자. kotlin GlobalScope.launch { withTimeout(10) { ... } } 일단 `withTimeout`의 코드를 살펴보자면 아래와 같다. 가장 아랫부분을 보면 time이 실제로 track되는 것은 CoroutineDispatcher의 구현이라고 적혀있다. Implementation note: how the time is tracked exactly is an implementation detail of the context's [CoroutineDispatcher]. kotlin / * Runs a given suspending [block
Coroutine Dispatcher
coroutine
2024. 3. 13.
Coroutines always execute in some context represented by a value of the CoroutineContext type, defined in the Kotlin standard library. The coroutine context is a set of various elements. The main elements are the Job of the coroutine, which we've seen before, and its dispatcher, which is covered in this section. The coroutine context includes a co
Coroutine Scope, Context
coroutine
2024. 3. 13.
To launch a coroutine, we need to use a coroutine builder like launch or async. These builder functions are actually extensions of the `CoroutineScope` interface. So, whenever we want to launch a coroutine, we need to start it in some scope. kotlin public interface CoroutineScope { / * The context of this scope. * Context is encapsulated by the scope and used for implementation
Integration
coroutine
2024. 3. 13.
kotlin interface Service { fun savePost(token: Token, item: Item): Call } suspend fun createPost(token: Token, item: Item): Post = serviceInstance.savePost(token, item).await() Let's say you want to use Coroutine with code that used futur (which corresponds to several libraries such as reactor). We are going to call 'savePost' which returns the future 'Call' from 'createPost'. I
공유객체 스레드 동기화
thread
2024. 3. 13.
동시에 읽고 쓰이는 공유 객체에서 스레드 동기화를 적절하게 사용하는 방법에 대해 알아보자. Atomic Synchronized block 스레드 한정 Mutex Actor AtomicInteger CAS(Compare And Swap) 알고리즘을 사용한다. 원리를 간단하게 말하자면, 변경하려는 값과 현재 저장된 값을 비교해서 같으면 변경하고 다르면 값을 변경하지 못하게 하는 것이다. 변경하려는 값과 현재 저장된 값이 다른 경우는 중간에 다른 스레드에 의해 값이 변경된 경우로 볼 수 있기에 변경을 허용하지 않는다. 사용법은 아래와 같다. kotlin suspend fun exampleFun(action: suspend () -Unit) { val n = 100 val k = 1
코루틴
coroutine
2024. 3. 13.
프로그래밍 언어에는 루틴이라는 개념이 있다. kotlin fun main() { ... val addedValue = plusOne(value) } fun plusOne(value: Int) { return value + 1 } 위와 같은 코드가 있다고 했을떄, main 함수가 메인루틴이고 함수를 호출해서 이동하는 것은 서브루틴이라고 부른다. 서브루틴은 진입하고, 빠져나오는 지점이 명확하다. 메인 루틴이 서브루틴을 호출하면, 서브루틴의 맨 처음 부분에 진입하여 return문을 만나거나 서브루틴의 닫는 괄호를 만나면 해당 서브루틴을 빠져나오게 된다. 그리고 진입점과 탈출점 사이에 쓰레드는 블락되어있다. 우리가 보통 짜는 코드는 이렇게 동작한다. 그러나 코루틴(Coro