Thread local usage #4

Closed
raggi opened this Issue Jul 9, 2010 · 4 comments

Projects

None yet

3 participants

@raggi
Member
raggi commented Jul 9, 2010

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
Collaborator
erikh commented Jul 10, 2010

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

@raggi
Member
raggi commented Jul 10, 2010

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

@erikh
Collaborator
erikh commented Jul 10, 2010

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

@pilcrow
Member
pilcrow commented Mar 17, 2013

Closing. Unclear to me what this applied to.

@pilcrow pilcrow closed this Mar 17, 2013
@pilcrow pilcrow was assigned Mar 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment