Issue #5654 has been updated by Santiago Pastorino.


As guys already said all the caveats I can think of are less important than allowing concurrent file loading
----------------------------------------
Feature #5654: Introduce global lock to avoid concurrent require
http://redmine.ruby-lang.org/issues/5654

Author: Hiroshi Nakamura
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0


=begin
Current implementation of "require" has locks for each file (expanded name from required feature) and serializes file loading from Threads.  The first Thread acquires the lock for the file and starts loading. The second Thread waits for acquiring the lock, and when the first Thread release the lock, it acquires the lock, then returns immediately.
This can cause deadlock by cross-require from Threads.

And code that does not properly use "require" could meet several problems;
 * constants can be defined before they're ready for use
 * classes can be modified while they're being used
 * global state can be initialized at the same time it's in use

Proposal: introduce global (per VM) lock to avoid concurrent file loading by "require" so that only one Thread can call "require" at the same time.

I don't have pros/cons list at this moment.  Let's discuss it, too.

Derived from a discussion at #5621 (thread-safe autoload)
=end



-- 
http://redmine.ruby-lang.org