一个高性能异步计算框架介绍

电子说

1.2w人已加入

描述

tachyonix:异步多生产单消费有界通道

这个库是 Asynchronix 的一个分支,它持续努力地构建用于系统仿真的高性能异步计算框架。 这是一个简洁的异步通道,以快速著称,但也不会在正确性和质量方面取巧。它的性能主要来自于对 MPSC 用例的关注和一些精心的优化,包括:

为全队列和空队列事件积极优化通知原语。

发送者一旦创建就不会再分配,即使对于被阻止的发送者 / 接收者通知。

没有任何自旋锁,并且热点路径(程序中那些会频繁执行到的代码)中没有互斥锁。

针对单个接收器优化的底层队列。

示例:


use tachyonix; use futures_executor::{block_on, ThreadPool}; let pool = ThreadPool::new().unwrap(); let (mut s, mut r) = tachyonix::channel(3); block_on( async move { pool.spawn_ok( async move { assert_eq!(s.send("Hello").await, Ok(())); }); assert_eq!(r.recv().await, Ok("Hello")); }); GitHub:https://github.com/asynchronics/tachyonix

 

rsre:重命名工具

使用指南:


USAGE: rsre FILE/DIRECTORY NEW_FULL_NAME OPTIONS: -h, --help Print help information -V, --version Print version information 示例:

# with mv mv ../../foo/bar/bat/foo.txt ../../foo/bar/bat/bar.txt # with rsre rsre ../../foo/bar/bat/foo.txt bar.txt GitHub:https://github.com/TheAwiteb/rsre

 

exun:错误处理

有许多我们不希望发生的错误,但即便错了我们也不希望 panic,当然我们也不想花太多时间处理意外错误。这就是本项目的用途,你可以保留意外错误,直到以后再担心它们。 示例:


use exun::*; fn foo(num: &str) -> Result { // 使用 `unexpect` 表示我们预计不会发生这个错误 let num = num.parse::().unexpect()?; Ok(num) }

use std::Error; use std::{self, Display}; use exun::*; #[derive(Debug)] struct NoNumberError; impl Display for NoNumberError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "no number provided") } } impl Error for NoNumberError {} fn foo(num: Option<&str>) -> Result> { let num = num.ok_or(NoNumberError)?; // 预计这可能会返回一个错误 let num = num.parse::().unexpect()?; // 但我们认为这个数字是可以解析的 Ok(num) }

use std::Error; use std::{self, Display}; use std::ParseIntError; use exun::*; #[derive(Debug)] struct NoNumberError; impl Display for NoNumberError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "no number provided") } } impl Error for NoNumberError {} fn foo(num: Option<&str>) -> Result> { // 预计可能不会得到一个数字,所以这样处理 let num = match num { Some(num) => num, None => return Err(Expected("no number provided")), }; // 但是,我们希望这个数字是可以解析的 match num.parse() { Ok(int) => Ok(int), Err(e) => Err(Unexpected(e)) } } GitHub:https://github.com/botahamec/exun

 

StarRust:太空射击游戏

使用 Rust 和 Bevy 制作的开源横向展开的太空射击游戏。 Demo:https://larsdu.github.io/StarRust/ GitHub:https://github.com/LarsDu/StarRust

cosmic-text:多行文本变形和渲染

COSMIC Text 提供了高级文本变形、布局和渲染。这些都被包含在一个简单抽象中。

文本变形由 rustybuzz 提供,并支持各种高级变形操作。

渲染由 swash 提供,它支持连字和彩色表情符号。

布局是在安全的 Rust 中自定义实现的,支持双向文本。  

      审核编辑:彭静
打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分