This is an automated email from the git hooks/post-receive script. henrich pushed a commit to branch debian/sid in repository jruby-joni.
commit d5e3f294aa28b8c4e2901ffa92f069f71df3b46c Author: Nick Sieger <[email protected]> Date: Sat Jan 12 05:56:52 2008 +0000 JRUBY-1941: Wrap WeakReference around stuff stored in ThreadLocals git-svn-id: http://svn.codehaus.org/jruby/joni/trunk@5555 961051c9-f516-0410-bf72-c9f7e237a7b7 --- src/org/joni/StackMachine.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java index 11aa350..7a3076f 100644 --- a/src/org/joni/StackMachine.java +++ b/src/org/joni/StackMachine.java @@ -19,6 +19,7 @@ */ package org.joni; +import java.lang.ref.WeakReference; import static org.joni.BitStatus.bsAt; import java.util.Arrays; @@ -66,12 +67,20 @@ abstract class StackMachine extends IntHolder implements StackType { stack = newStack; } - static final ThreadLocal<StackEntry[]> stacks = new ThreadLocal<StackEntry[]>(); + static final ThreadLocal<WeakReference<StackEntry[]>> stacks + = new ThreadLocal<WeakReference<StackEntry[]>>() { + @Override + protected WeakReference<StackEntry[]> initialValue() { + return new WeakReference<StackEntry[]>(allocateStack()); + } + }; + private static StackEntry[] fetchStack() { - StackEntry[] stack = stacks.get(); + WeakReference<StackEntry[]> ref = stacks.get(); + StackEntry[] stack = ref.get(); if (stack == null) { - stacks.set(stack = allocateStack()); - return stack; + ref = new WeakReference<StackEntry[]>(stack = allocateStack()); + stacks.set(ref); } return stack; } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

