ITPub博客

首页 > 数据库 > 数据库开发技术 > 【Rust日报】2019-12-19 Writing BPF code in Rust

【Rust日报】2019-12-19 Writing BPF code in Rust

原创 数据库开发技术 作者:Rust语言中文社区 时间:2019-12-20 10:38:34 0 删除 编辑

Tokio v0.2.5 版本更新

Includes new APIs, utilities, and fixes. Some highlights:

tokio::sync::broadcast

tokio::sync::Semaphore

A multi-producer, multi-consumer channel where each sent value is sent to all consumers (fan-out). The channel is bounded and when consumers lag, they will receive an error indicating they have lagged too far behind.

example 1:

use tokio::sync::broadcast;

#[tokio::main]
async fn main() {
let (tx, mut rx1) = broadcast::channel(16);
let mut rx2 = tx.subscribe();

tokio::spawn(async move {
assert_eq!(rx1.recv().await.unwrap(), 10);
assert_eq!(rx1.recv().await.unwrap(), 20);
});

tokio::spawn(async move {
assert_eq!(rx2.recv().await.unwrap(), 10);
assert_eq!(rx2.recv().await.unwrap(), 20);
});

tx.send(10).unwrap();
tx.send(20).unwrap();
}


tokio-compat 0.1.1版本发布

Tokio 0.2 使用 std::future 和 async/await 使得 Tokio 编写异步代码更加符合人体工程学,并且新的调度器使 Tokio 0.2 的线程池快了 10 倍。然而,更新现有的 Tokio 0.1 将是个难题。Tokio Compat 这个库就是为了解决这个问题,它提供与 Tokio 0.1 和 Tokio 0.2 未来兼容的运行时。

使用示例

Spawning both tokio 0.1 and tokio 0.2 futures:

use futures_01::future::lazy;

tokio_compat::run(lazy(|| {
// spawn a `futures` 0.1 future using the `spawn` function from the
// `tokio` 0.1 crate:
tokio_01::spawn(lazy(|| {
println!("hello from tokio 0.1!");
Ok(())
}));

// spawn an `async` block future on the same runtime using `tokio`
// 0.2's `spawn`:
tokio_02::spawn(async {
println!("hello from tokio 0.2!");
});

Ok(())
}))

查看原文:https://tokio.rs/blog/2019-12-compat/

Writing BPF code in Rust

如果你做系统编程,你可能最近经常听说BPF。它是一种新的热门 Linux 技术,允许在内核中运行用户提供的程序。Netflix、Facebook、谷歌、Cloudflare 和其他许多公司都在使用它来实现快速的负载平衡、DDoS 缓解和性能监控等功能。

原文请看:https://blog.redsift.com/labs/writing-bpf-code-in-rust/

reddit 参与讨论:https://www.reddit.com/r/rust/comments/ecspjx/writing_bpf_code_in_rust/

壁纸来一发

原图真的不错,reddit 原文:https://www.reddit.com/r/rust/comments/echv8s/my_rust_holiday_wallpaper/

招聘信息

@NEARProtocol is looking for a WebAssembly & Compiler Engineer

🇺🇸 San Francisco / New York 🇩🇪 Berlin 🇷🇺 Moscow 🌍 Remote allowed!

原文链接:https://t.co/iL4s9gAcc8?amp=1


From 日报小组 @Jancd

日报订阅地址:

独立日报订阅地址:

  • Telgram Channel

  • 阿里云语雀订阅

  • Steemit

  • GitHub

社区学习交流平台订阅:

  • Rust.cc论坛: 支持rss

  • Rust Force: 支持rss

  • 微信公众号:Rust语言学习交流


原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。

上一篇: Rust 1.40 如期而至
请登录后发表评论 登录
全部评论

注册时间:2020-06-11

  • 博文量
    1769
  • 访问量
    718485