• GengTeng
    2021-11-30
    我之前记录并翻译过无船同志(withoutboats)的一个讲座,供大家参考:https://gteng.org/2021/01/30/zero-cost-async-io/

    作者回复: 👍

    共 2 条评论
    6
  • 罗同学
    2021-11-29
    Pin了后的数据 所有者变成谁了?

    作者回复: 所有者还是之前的变量,只不过一般会把它 shadow 掉,这样没有人可以拿到。当这个变量离开作用域时还是会被回收。 ```rust use std::pin::Pin; fn main() { let s = "hello".to_string(); println!("addr of s(stack): {:p}", &s); let s = Pin::new(s); println!("addr of pinned s: {:p}", &s); } ```

    
    3
  • dva
    2021-12-18
    Box<T>是Unpin,因为Box<T>实现了Unpin trait

    作者回复: 👍

    
    1
  • wowotuo
    2022-01-12
    讲得很牛逼,现在反反复复听了看了不下10次

    作者回复: 👍

    
    
  • 良师益友
    2021-11-29
    以前在这里卡住了,这次说明白了,感谢老师

    作者回复: 👍

    
    
  • 清风徐来
    2022-02-22
    有了Pin为啥还有!UnPin
    共 2 条评论
    1
  • Rustlab
    2023-03-15 来自湖南
    我越看越困惑, write_hello_file_async("/tmp/hello").await?;这里,如果只是生成loop,那这就是同步代码了,能详细讲一讲, write_hello_file_async("/tmp/hello").await?;在调用处是如何被处理,其如何注册到异步运行时、最后future的poll方法是怎么样被不断重复调用的吗?这里的poll里面有一个loop,我感觉真实场景不会这么干吧。
    
    
  • Rustlab
    2023-03-15 来自湖南
    我越看越困惑, write_hello_file_async("/tmp/hello").await?;这里,如果只是生成loop,那这就是同步代码了,能详细讲一讲, write_hello_file_async("/tmp/hello").await?;在调用处是如何被处理,其如何注册到异步运行时、最后future的poll方法是怎么样被不断重复调用的吗?这里的poll里面有一个loop,我感觉真实场景不会这么干吧。
    
    
  • 约书亚
    2022-11-23 来自天津
    有些凌乱,在第二个move_creates_issue示例(使用了Pin的那个)里,move_it无法调用是因为原来的SelfReference类型的data(值)被shadow了,如果把data改个名字,move_it依旧可以调用,和Pin没啥关系? 不过如果将move_it与它上面的那条语句互换下位置,确实会编译不通过,原因是在有借用的情况下移动,那这么说我不使用Pin,随便使用一个&SelfReference或者&mut SelfReference,也能阻止移动呢?
    共 3 条评论
    
  • doubled
    2022-11-13 来自福建
    老师能具体讲讲phantomdata么,在Waker中为什么marker要是phantomdata<fn(&'a ())->&'a ()>,能不能使用phantomdata<&'a ()>或者使用phantomdata<&'a mut ()>
    
    