编程语言当前并发思路比较

编程语言当前并发思路比较

Andy erpingwu@gmail.com
2012/02/17-2013/07/25

肤浅地比较一下,感觉编程语言当前对并发(这里暂不讨论传统线程模式)的思路基本一致:

  • 将大的分布式系统通过消息通信增强并发的概念缩小到进程内。
  • coroutine 方面则是将大而重的系统调度部分转为线程内轻量的自主调度。
go-lang

Do not communicate by sharing memory; instead, share memory by communicating.
http://golang.org/doc/effective_go.html#concurrency

rust-lang

Instead of manipulating shared storage, Rust tasks communicate with one another using a typed, asynchronous, simplex message-passing system.
http://doc.rust-lang.org/doc/rust.html#tasks

erlang

Processes communicate by sending and receiving messages … Message sending is asynchronous and safe, the message is guaranteed to eventually reach the recipient, provided that the recipient exists
http://www.erlang.org/doc/reference_manual/processes.html

scala

是深受erlang影响的 actor, 惊叹号都一样。Scala 2.10 改用 akka.actor。
Actors are very lightweight concurrent entities. They process messages asynchronously using an event-driven receive loop. Pattern matching against messages is a convenient way to express an actor's behavior.
http://docs.scala-lang.org/overviews/core/actors.html
http://akka.io/

c++

c++11 也对并发做了大量工作,但都是线程与Atomic,主要是支持了 memory order。 boost 库倒是有提供 Coroutine,同时 boost.asio 有一个例子 A single-threaded HTTP server implemented using stackless coroutines.

libprocess Library that provides an actor style message-passing programming model (in C++). 这个用在 mesos

python

cpython略过

pypy

支持 Stacklessgreenlets]。

stackless

Microthreads tasklets wrap functions allowing them to be launched as microthreads.
Channels channels can be used for bidirectional communication between tasklets.

greenlet

The “greenlet” package is a spin-off of Stackless, a version of CPython that supports micro-threads called “tasklets”. Tasklets run pseudo-concurrently (typically in a single or a few OS-level threads) and are synchronized with data exchanges on “channels”.

转载于:https://my.oschina.net/erpingwu/blog/144477

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值