开发者

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

开发者 https://www.devze.com 2022-12-17 05:00 出处:网络
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 s

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

精彩评论

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