RDBI / rdbi

rdbi is an attempt to rewrite the core of Ruby/DBI.
MIT License
40 stars 7 forks source link

Thread local usage #4

Closed raggi closed 11 years ago

raggi commented 14 years ago

In order to be a good citizen, the ideal thing is to try to reduce the volume of thread local usage.

There are a few approaches to this, but one that can work quite well is to store a key for the thread by package. The problem with this approach is that it could create small reference leaks:

@thread_locals = Hash.new { |h,k| h[k] = {} }
@thread_locals[Thread.current.object_id][:foo] = :something

Cleaning this up can be hard, but for pooled data it should be possible to have hooks in the pool to clean it up.

erikh commented 14 years ago

Hrm. So you're saying that attr_threaded_accessor is the wrong approach?

raggi commented 14 years ago

I'm not sure tbh, the problem is that thread local storage is basically globals.

erikh commented 14 years ago

Right, attr_threaded_accessor basically obfuscates that; check the impl out in methlab.

pilcrow commented 11 years ago

Closing. Unclear to me what this applied to.