-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 (2011/11/18 14:05), Charles Oliver Nutter wrote: >> # test.rb t1 = Thread.new { require "foo"; Foo } t2 = Thread.new >> { require "bar"; Bar } > > The problem here is caused by require having a lock per file. At > the time it was added, I believe I warned it would cause deadlocks > in the future. Sure. This deadlock from cross-require is intentional at this moment I believe, and that's the reason for the warning 'loading in progress, circular require considered harmful'. Related discussion is at #920. I don't know how Java's classloader avoids this problem. > Yehuda's simple case could be solved by having all autoloads > synchronized against a single lock; only *either* the Foo autoload > or the Bar autoload could fire, and then the other would fire once > it had completed. I understand that it's not an autoload issue but a concurrent require issue, and 'disallowing concurrent requires entirely' in #920 is hard jump for Ruby... So I hope someone extract requirements from Yehuda's case for solving Rails' issue, not by changing require/autoload directly. I don't have enough time for it now but there would be some more related assumptions around it I guess. For example, they don't want to let developers write 'require' explicitly, a convention for Ruby's module hierarchy that must sync with filesystem layout, etc... // NaHi -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) iQEcBAEBAgAGBQJOxfZjAAoJEC7N6P3yLbI2bjkIAOdoIvo9QOgUB62bFc/FcHu1 sFqrTlNjP6kaNHIHH2nyvWpj7OprytZ6GVzRXBY1QUTvh9u/Y8LaJ6Zhida7mtH9 tmDmHK6+Z5qTvo9TwJmfd7hXTUxwfAxvoipw3OHVMbS0lFNJNDup7wNn6pQh1f0v h1Pl9lverUO6U51o/1e24YotyVKvfpLqogOnRPCfTVnITYmovBxz80GHz06FnFyg Hr7xxG0dHkNk+L3Fk+rHuvh8xpjtBe74z69GYevGSsgSe973KIpjWrjuaNYUjekJ cfoDVjyrhS1swijFY89n2ziJheuFUW9Zerzw2T+7gG0nWCc69TNNJdVfzE1+E9g= =qkO8 -----END PGP SIGNATURE-----