Rust Async Programming

오늘은 Rust에서 제공하는 Asynchronous Programming 관련 feature들에 대해 정리하면서, async 관련 포스트를 쓸 때 마다 사용되는 단어들, async, future, runtime, executor에 대해 정리해 보겠습니다. 오늘은 유독 내용이 추상적인 느낌에 부족한 부분이 많은 것 같은데, 틀린 부분이나 부족한 부분이 있다면 코멘트 남겨 주세요 :) Asynchronous Programming Async book에는 Asynchronous programming이 다음과 같이 정의되어 있습니다. Asynchronous programming, or async for short, is a concurrent programming model supported by an increasing number of programming languages....

2022-09-11 · 7 min · 1415 words · Huijeong Kim

Async Rust에서 mpsc queue 사용하기

mpsc(multi produce single consumer) queue는 thread 간 message를 주고받는 channel로 많이 쓰입니다. std mpsc와 crossbeam channel가 많이 쓰이는 mpsc channel이고, async rust에서는 tokio mpsc를 사용할 수 있습니다. async rust에서 mpsc queue를 사용하는 방법을 알아보겠습니다. 1. std::sync::mpsc 사용하기 가장 먼저 std 라이브러리의 mpsc를 사용해 볼 수 있겠습니다. Async rust에서 mpsc를 사용하려면 여러 future들이 message sender(tx)를 갖고 있고 하나의 future가 message receiver(rx)를 갖고 있어야 합니다. mpsc의 Sender는 clone 가능하므로 다음과 같이 tx를 clone하여 여러 Future가 message channel을 공유할 수 있습니다....

2022-08-27 · 8 min · 1596 words · Huijeong Kim