rails/rails — pull request #10156 by wangjohn (2013-04-09 23:07:23+00:00)
Title: Grouping thread locals in ActiveRecord

I've grouped together thread local variables in ActiveRecord using a new class ``RuntimeRegistry`` which stores the local variables. Now, instead of storing the local variables individually in ``Thread.current``, you can store the entire ``RuntimeRegistry`` object in ``Thread.current``.

This cuts down on the number of thread locals.

To do this, I've created a new module ``PerThreadRegistry`` which can be included in any class to add a ``self.instance`` method, which will create a new instance in ``Thread.current`` of the base class.