async task:构建执行者的任务抽象 源码

上传:jeopardy7926 浏览: 14 推荐: 0 文件:ZIP 大小:40.69KB 上传时间:2021-04-04 18:58:07 版权申诉
异步任务 用于构建执行程序的任务抽象。 要将将来生成到执行程序上,我们首先需要在堆上分配它,并使它保持一些状态。 状态指示将来是否已准备好轮询,等待唤醒或完成。 这样一个有状态的未来被称为一项任务。 所有执行者都有一个队列,其中包含计划的任务: let (sender, receiver) = flume :: unbounded (); 使用spawn() , spawn_local()或spawn_unchecked()创建一个任务,它们返回一个Runnable和一个Task : // A future that will be spawned. let future = async { 1 + 2 }; // A function that schedules the task when it gets woken up. let schedule = move | ru
上传资源
用户评论