Skip to main content

Module select

Module select 

Source
Expand description

Select macro for waiting on multiple async operations 用于等待多个异步操作的select宏

§Overview / 概述

This module provides a foundation for the select! macro which allows waiting on multiple async operations and proceeding with the first one that completes.

本模块为 select! 宏提供基础,允许等待多个异步操作并处理第一个完成的。

§Example / 示例

use hiver_runtime::select;
use hiver_runtime::time::{sleep, Duration};

async fn example() {
    let sleep1 = sleep(Duration::from_millis(100));
    let sleep2 = sleep(Duration::from_millis(200));

    select! {
        _ = sleep1 => println!("First completed"),
        _ = sleep2 => println!("Second completed"),
    }
}

Structs§

SelectMultiple
Select future for multiple futures 多个future的select future
SelectMultipleBinding
Internal helper for select macro binding select宏绑定的内部辅助
SelectTwo
Select future for two futures 两个future的select future

Enums§

SelectMultipleOutput
Output of selecting from multiple futures 从多个future中选择的输出
SelectTwoOutput
Output of selecting between two futures 两个future之间选择的输出

Functions§

select_multiple
Select from multiple futures 从多个future中选择
select_two
Select from two futures, returning the first that completes 从两个future中选择,返回第一个完成的