Ruby 1.9.1中的本机线程,对我有什么好处? [英] Native threads in Ruby 1.9.1, whats in it for me?

查看:138
本文介绍了Ruby 1.9.1中的本机线程,对我有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,Ruby 1.9.1现在声明稳定。 Rails应该与它一起工作,并缓慢地将宝石移植到它。

So, Ruby 1.9.1 is now declared stable. Rails is supposed to work with it and slowly gems are being ported to it.

它有本机线程和一个全局解释器锁(GIL)。

It has native threads and a global interpreter lock (GIL).

由于GIL已经就位,原生线程在1.9.1中是否会提供任何类型的优势?

Since a GIL is in place, do native threads offer any kind of benefit over green threads in 1.9.1?

推荐答案

我认为最大的胜利是C基础扩展可以释放GIL 。因此,例如,MySQL适配器可以干净地运行长时间运行的数据库查询,而不会阻塞所有其他Ruby线程。

I think the big win, is that C based extensions can release the GIL. So, for example, a MySQL adapter can quite cleanly run long running database queries without blocking up all the other Ruby threads.

这篇关于Ruby 1.9.1中的本机线程,对我有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆