您的位置 首页 > 腾讯云社区

【Rust日报】2020-04-27 - smol异步库,teleforking, traits---MikeLoveRust

smol - 一个快捷有短小精悍的Rust异步运行环境库)

smol (@stjepang) - A small and fast async runtime for Rust https://github.com/stjepang/smol

这个运行环境库扩展了rust语言标准类库 并结合了异步机制,仅用1500行代码写成!请大家阅读文档 并参考提供的例子这样就可以开始自己动手写具有异步运行机制的程序了。

这个运行库的异步实现机制在Linux/Android上用epoll在macOS/iOS/BSDkqueue在Windows上用wepoll分别用不同的底层技术实现。

功能:

异步TCP,UDP,Unix domain sockets,自定义的file descriptors."Send!"执行器采用本地线程。Work-stealing执行器能对各种不同的workloads(负载)自适应。阻塞执行器可以用在包括文件,进程和标准I/O上。执行任务可以取消Userspaces Timers计时器

代码例子:需要在examples文件夹中来运行,具体例子执行如下 --

$ cd examples$ ls$ cargo run --example ctrl-c

兼容性:看这些例子可以明白smol是怎么可以跟别的异步运行库混用的,包括: async-std,tokio, surf, reqwest

其中有一个非常重要的功能可以无缝的集成全部使用tokio作为依赖的库包,它创建一个global tokio运行库并在smol里面直接设置内容, 可以通过下面的方式激活这个功能:

[dependencies]smol = { version = "0.1", features = ["tokio02"] }

下面是文档生成方式:

cargo doc --document-private-items --no-deps --open细思极恐的Teleforking - 在另外一个计算机"远程启动"一个计算进程!

Teleforking a process onto a different computer! https://thume.ca/2020/04/18/telefork-forking-a-process-onto-a-different-computer/

一个用rust语言实现的细思极恐的Teleforking远程启动进程功能。大家围观,不要拿来做坏事哈!

用rust语言的Traits数据结构实现高阶排序"欺骗"!

Cheating Higher Ranks with Traits。 https://leshow.github.io/post/cheat_rank_n/

---来自腾讯云社区的---MikeLoveRust

关于作者: 瞎采新闻

这里可以显示个人介绍!这里可以显示个人介绍!

热门文章

留言与评论(共有 0 条评论)
   
验证码: