From: Roger Pack Date: 2008-12-04T08:44:29+09:00 Subject: [ruby-core:20275] Re: autoload and concurrency On Tue, Dec 2, 2008 at 11:10 PM, Charles Oliver Nutter wrote: > Require could be made safe if only one thread were allowed to execute > requires at a time, globally. Whether that's a reasonable tradeoff, I'm not > sure. > > All things are possible...but many require behavioral changes to Ruby. > > - Charlie That might be a great idea. The only drawback being if you have file2.rb: sleep run this: Thread.new { sleep 1; require 'file1'} require 'file2' So if one thread is "happily running" within a require file [rails does this?] then other threads would be prohibited from requiring. Or I guess it could be mutex-ified per autoload [like require is currently for 1.9]--i.e. when a second thread loads the same constant, have it wait till the first's auto-load returns [somewhat of a band-aid, but...hmm this is hard]. -=R