View | Details | Raw Unified | Return to bug 570670 | Differences between
and this patch

Collapse All | Expand All

(-)a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexReader.java (-4 / +12 lines)
Lines 169-177 public abstract class IndexReader Link Here
169
        protected ArrayIntCompressed getPage(int page)
169
        protected ArrayIntCompressed getPage(int page)
170
        {
170
        {
171
            SoftReference<ArrayIntCompressed> ref = pages.get(page);
171
            SoftReference<ArrayIntCompressed> ref = pages.get(page);
172
            if (ref != null && ref.get() != null)
172
            if (ref != null)
173
            {
173
            {
174
                return ref.get();
174
                ArrayIntCompressed cached = ref.get();
175
                if (cached != null)
176
                {
177
                    return cached;
178
                }
175
            }
179
            }
176
180
177
            // no read is ready with a complete read; do a read
181
            // no read is ready with a complete read; do a read
Lines 195-203 public abstract class IndexReader Link Here
195
            {
199
            {
196
                // if another thread finished a concurrent read, use it
200
                // if another thread finished a concurrent read, use it
197
                ref = pages.get(page);
201
                ref = pages.get(page);
198
                if (ref != null && ref.get() != null)
202
                if (ref != null)
199
                {
203
                {
200
                    return ref.get();
204
                    ArrayIntCompressed cached = ref.get();
205
                    if (cached != null)
206
                    {
207
                        return cached;
208
                    }
201
                }
209
                }
202
210
203
                // if this thread is first, it can store
211
                // if this thread is first, it can store
(-)a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java (-2 / +3 lines)
Lines 533-540 public abstract class IndexWriter Link Here
533
    {
533
    {
534
        static class IndexedThreadLocalCache<T>
534
        static class IndexedThreadLocalCache<T>
535
        {
535
        {
536
            // because it is ThreadLocal, it is always only this thread, no sync required
536
            final ThreadLocal<Integer> pageNumber = ThreadLocal.withInitial(() -> -1);
537
            final ThreadLocal<Integer> pageNumber = ThreadLocal.withInitial(() -> -1);
537
            final ThreadLocal<SoftReference<T>> page = ThreadLocal.withInitial(() -> null);
538
            final ThreadLocal<SoftReference<T>> page = ThreadLocal.withInitial(() -> new SoftReference(null));
538
539
539
            void set(int pageNumber, T page)
540
            void set(int pageNumber, T page)
540
            {
541
            {
Lines 619-626 public abstract class IndexWriter Link Here
619
620
620
        public void set(int index, int value)
621
        public void set(int index, int value)
621
        {
622
        {
622
            ArrayIntCompressed array = getPage(index / pageSize);
623
            // TODO unlock this by having ArrayIntCompressed use atomics
623
            // TODO unlock this by having ArrayIntCompressed use atomics
624
            ArrayIntCompressed array = getPage(index / pageSize);
624
            // uses bit operations internally, so we should sync against the page
625
            // uses bit operations internally, so we should sync against the page
625
            synchronized(array)
626
            synchronized(array)
626
            {
627
            {

Return to bug 570670