有时间就更一更
zhangsoledad / salon Goto Github PK
View Code? Open in Web Editor NEWSoledad's Salon
Home Page: https://zhangsoledad.github.io/salon/
License: GNU General Public License v2.0
Soledad's Salon
Home Page: https://zhangsoledad.github.io/salon/
License: GNU General Public License v2.0
引用Rob Pike的经典描述:
Concurrency is about dealing with lots of things at once.
Parallelism is about doing lots of things at once.
并发是同一时间应对(dealing with)多件事的能力;
并行是同一时间做(doing)多件事的能力;
并发编程的概念越来越广泛的收到关注,主要驱动力就在于如今我们正处于“多核危机”。CPU的单核性能一直没有重大的提升突破,目前CPU的发展模式变成了堆核和如何有效的堆核。
线程和锁
线程和锁模型是对底层硬件运行过程的形式化,
几乎所有的编程语言都对线程和锁提供了支持,rust也不例外,这种模型的优点在于非常简单直接,使用起来没有限制,但也是缺点所在,编程语言没有提供足够的帮助,使得程序容易出错,也要面临死锁的问题。
channel
Don't communicate by sharing memory; share memory by communicating
出了传统的锁之外,rust也提供了CSP模型的channel用于线程间通信。
缺失select。https://doc.rust-lang.org/stable/std/macro.select.html
原子类型 CAS
原子类型无锁, CAS,不会死锁,问题:swap 调用时,其他线程修改了原子变量的值,swap重试,swap必须无副作用。
https://aturon.github.io/blog/2015/08/27/epoch/
https://github.com/crossbeam-rs/crossbeam
线程 stack 保存挂起状态,linux 2MB,切换 数钱纳秒,还与stack 大小相关。
线程池 CPU密集,是线程复用。 IO型,堵塞。
事件驱动,future
https://docs.rs/futures/0.1.16/futures/
CPS变换
https://github.com/carllerche/tokio-serde-json/blob/master/src/lib.rs
https://github.com/alexcrichton/futures-await
coroutine
rust-lang/rust#43076
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.