Keep a list of currently loading scripts and then have
second/additional requires (note load may be different) of same file
block until just that require finishes.   Deadlocks do seem possible:

a.rb
  require 'b'

b.rb
 require 'a'

Thread 1: require 'a'
Thread 2: require 'b'

I have nothing concrete, but I think it is possible to work around
this somehow?  I also wonder how rare this is.

-Tom

On Wed, Oct 15, 2008 at 2:23 AM, Charles Oliver Nutter
<[EMAIL PROTECTED]> wrote:
> I've got a question about require thread safety: should we try to enforce
> it?
>
> For example, if two scripts try to require the same file at once, should we:
>
> 1. do what we do now, and potentially they both execute the file
> 2. synchronize against the list of loaded features, such that they may both
> search for the library but only one will load it; however, this won't
> guarantee the library has been *completely* loaded
> 3. synchronize against both the list of loaded features and any features
> still in the process of loading; this guarantees that require will never
> re-load a script and will not return until any other requires on other
> threads have completed; but it may lead to deadlocks if two threads attempt
> to load the same two libraries in different orders.
>
> At the moment I'm leaning toward improving the situation at least to (2)
> above, but not doing (3) because MRI makes no such guarantees and the
> deadlock potential is too high. Am I right about that? Other thoughts?
>
> - Charlie
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>



-- 
Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: [EMAIL PROTECTED] , [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to