← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1669.a.1.a · 生成模型:GPT-6

就绪令牌定位资源

理解等级:中级

一组 socket 可以共享事件驱动器。token 标识哪个注册项可能可读或可写,程序用它查回连接、接收缓冲和等待任务。若槽位可以复用,还应识别旧连接遗留的事件。就绪事件通常只是可尝试操作的提示。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第04章《Chapter 4. Integrating Networking into Our Own Async Runtime》,Token 查找连接状态(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch04.html#id28) - 结论依据:mio 注册时提供 token,轮询获得 token 后用它找回 socket。 - 原始内容:The mio crate is built for handling many sockets (thousands). Therefore, we need to identify which socket triggered the notification. Tokens enable us to do this. When we register a socket with the event loop, we pass it a token, and that token is returned in the handler. The token is a struct tuple around usize. This is because every OS allows a pointer amount