
Tokio & Async I/O
Tokio runtime、async tasks、select!、join!、timeout、tokio::spawn、async ファイル/ネットワーク I/O
22 面接問題·
Senior
1非同期 Rust アプリケーションにおける Tokio runtime の主な役割は何ですか?
1
非同期 Rust アプリケーションにおける Tokio runtime の主な役割は何ですか?
回答
Tokio runtime は、future が完了するまで poll する executor を提供します。また、複数の OS thread にタスクを分散させるためのマルチスレッド scheduler(デフォルト)と、非同期 I/O 操作のための reactor も管理します。runtime がなければ、Rust の future はデフォルトで lazy なため何も実行しません。
2#[tokio::main] マクロを使って Tokio runtime を初期化するにはどうすればよいですか?
2
#[tokio::main] マクロを使って Tokio runtime を初期化するにはどうすればよいですか?
回答
#[tokio::main] マクロは、async な main() 関数を、マルチスレッドの Tokio runtime を作成して async 関数を実行する同期的なエントリポイントに変換します。このマクロは、runtime を作成し、メインの future が完了するまでブロックするために必要な boilerplate を自動的に生成します。
3#[tokio::main] と #[tokio::main(flavor = "current_thread")] の違いは何ですか?
3
#[tokio::main] と #[tokio::main(flavor = "current_thread")] の違いは何ですか?
回答
デフォルトでは、#[tokio::main] は worker thread のプールにタスクを分散するマルチスレッド runtime を作成します。flavor = "current_thread" を指定すると、runtime はすべてのタスクをメインスレッド上のみで実行します。これはテスト、シンプルなアプリケーション、または thread 間でのデータ共有を避けたい場合に役立ちます。
4
tokio::spawn() は何をし、どの型を返しますか?
5
tokio::spawn() に渡される future が 'static でなければならないのはなぜですか?
+19 面接問題
その他のRust面接トピック
Rustの基礎
Junior
25問Ownership & Borrowing
Junior
22問Structs & Enums
Junior
20問エラー処理
Junior
18問コレクション
Junior
20問モジュールとパッケージ
Junior
18問Traits
Mid-Level
22問Generics
Mid-Level
20問Lifetimes
Mid-Level
20問Iterators & Closures
Mid-Level
22問Smart Pointers
Mid-Level
22問Concurrency Basics
Mid-Level
20問async/await
Mid-Level
22問Testing
Mid-Level
18問Cargo & Ecosystem
Mid-Level
18問Pattern Matching
Mid-Level
18問マクロ
Mid-Level
20問Serde とシリアライゼーション
Mid-Level
20問Unsafe Rust
Senior
20問高度なトレイト
Senior
22問高度な lifetime
Senior
20問Type System
Senior
20問パフォーマンス最適化
Senior
20問Memory Management
Senior
20問Web Frameworks
Senior
22問Database Integration
Senior
20問Rust デザインパターン
Senior
20問