2008/12/21 Charles Oliver Nutter <charles.nutter / sun.com>: > Gary Wright wrote: >> >> I admit to not thinking about this too much but shouldn't there be a >> global lock on things like require and load? If it isn't enforced by Ruby >> itself, I would think that a properly designed multi-threaded application >> shouldn't have multiple threads contending for access to global state >> without proper locking. > > It certainly could, but that is a behavioral change; there's no way to > require files in separate threads at the same time. Of course, maybe it's a > bad idea to allow that in the first place. I don't think there should be locking involved for "load" as that loads a file unconditionally. When using "load" one must be aware of the fact that the file can be loaded multiple times - including concurrently. For "require" the story looks a bit different. If I am not mistaken you would need a reentrant lock per (case insensitive? - probably depending on file system) string after "require" as the smallest granularity. Hm... The longer I think about it the more I believe that a single reentrant lock for "require" is probably the most robust solution... While we're at it: what happens to "require" in light of changes to $: and current directory? Kind regards robert -- remember.guy do |as, often| as.you_can - without end