其他语言的Erlang式并发 [英] Erlang-style Concurrency for Other Languages
问题描述
注意:我在其他编程语言中存在什么库,以提供Erlang式并发模型(进程,邮箱,模式匹配接收等)我特别感兴趣的是与Erlang类似的东西,不仅仅是任何线程或排队库。
消息传递接口(MPI)( http://www-unix.mcs.anl.gov/mpi/)是用于并行编程的高度可扩展和强大的库,适用于C,但现在可用于多种风格 http://en.wikipedia.org/wiki/Message_Passing_Interface#Implementations 。虽然库不会引入新的语法,但它提供了一个通信协议来协调可并行化的例程之间的数据共享。
传统上,它用于大型集群计算而不是单一的并发系统,尽管多核系统肯定可以利用这个库。
并行编程问题的另一个有趣的解决方案是OpenMP,这是试图在各种平台上提供便携式扩展,以向编译器提供关于哪些代码段易于并行化的提示。
例如( http://en.wikipedia.org/wiki/OpenMP#Work-sharing_constructs ):
#define N 100000
int main(int argc,char * argv [])
{
int i,a [N];
#pragma omp并行为
为(i = 0; i< N; i ++)
a [i] = 2 * i;
return 0;
}
当然有两个优点和缺点,但前者已被证明在学术界和其他重型科学计算应用中取得极大的成功。 YMMV。
What libraries exist for other programming languages to provide an Erlang-style concurrency model (processes, mailboxes, pattern-matching receive, etc.)?
Note: I am specifically interested in things that are intended to be similar to Erlang, not just any threading or queueing library.
Message Passing Interface (MPI) (http://www-unix.mcs.anl.gov/mpi/) is a highly scalable and robust library for parallel programming, geared original towards C but now available in several flavors http://en.wikipedia.org/wiki/Message_Passing_Interface#Implementations. While the library doesn't introduce new syntax, it provides a communication protocol to orchestrate the sharing of data between routines which are parallelizable.
Traditionally, it is used in large cluster computing rather than on a single system for concurrency, although multi-core systems can certainly take advantage of this library.
Another interesting solution to the problem of parallel programming is OpenMP, which is an attempt to provide a portable extension on various platforms to provide hints to the compiler about what sections of code are easily parallelizable.
For example (http://en.wikipedia.org/wiki/OpenMP#Work-sharing_constructs):
#define N 100000
int main(int argc, char *argv[])
{
int i, a[N];
#pragma omp parallel for
for (i=0;i<N;i++)
a[i]= 2*i;
return 0;
}
There are advantages and disadvantages to both, of course, but the former has proven to be extremely successful in academia and other heavy scientific computing applications. YMMV.
这篇关于其他语言的Erlang式并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!