开发者

What work-arounds can be applied to thread-unsafe autoload in ruby?

As mentioned in this question, autoloading within a thread can cause problems. Wha开发者_如何学Ct work-arounds can be applied?


You can simply require the files containing the classes you need, before spawning threads. It is a bit more work to get running than simply using autorequires, but it is necessary here.

That way you avoid having a class being loaded on multiple threads due to racing conditions.


You could roll your own with a const_missing plus a Mutex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜