美文网首页
[async_std]--2--Async concepts u

[async_std]--2--Async concepts u

作者: buddyCoder | 来源:发表于2020-03-11 16:57 被阅读0次

    Async concepts using async-std

    Rust Futures have the reputation of being hard. We don't think this is the case. They are, in our opinion, one of the easiest concurrency concepts around and have an intuitive explanation.
    [Rust Futures]的名声说它很难。我们认为情况并非如此。在我们看来,它们是最简单的并发概念之一,并且有一个直观的解释。

    However, there are good reasons for that perception. Futures have three concepts at their base that seem to be a constant source of confusion: deferred computation, asynchronicity and independence of execution strategy.
    然而,这种看法有充分的理由。Futures 有三个基本概念,似乎是经常引起混乱:延迟计算,异步性和执行策略的独立性。

    These concepts are not hard, but something many people are not used to. This base confusion is amplified by many implementations oriented on details. Most explanations of these implementations also target advanced users, and can be hard for beginners. We try to provide both easy-to-understand primitives and approachable overviews of the concepts.
    这些概念并不难,但很多人并不习惯。许多面向细节的实现放大了这种基本混淆。对这些实现的大多数解释也针对高级用户,对初学者来说可能很难。我们试图提供易于理解的原语和概念的可接近的概述。

    Futures are a concept that abstracts over how code is run. By themselves, they do nothing. This is a weird concept in an imperative language, where usually one thing happens after the other - right now.
    Futures 是一个概念,它抽象了代码是如何运行的。他们一个人什么也不做。在命令式语言中,这是一个奇怪的概念,通常一件事发生在另一件事之后——现在。

    So how do Futures run? You decide! Futures do nothing without the piece of code executing them. This part is called an executor. An executor decides when and how to execute your futures. The async-std::task module provides you with an interface to such an executor.

    那么,Futures 如何运行?你决定!如果没有这段代码的执行,Futures 就啥都不干。这部分被称为“executor”。executor决定何时以及如何执行你的futures。“async_std::task”模块为您提供了这样一个executor 的接口。
    Let's start with a little bit of motivation, though.
    不过,让我们先从一点动力开始。

    相关文章

      网友评论

          本文标题:[async_std]--2--Async concepts u

          本文链接:https://www.haomeiwen.com/subject/bofhjhtx.html