/** Computes results from proxied lookups. * @param indexToCache 0 = allInstances, 1 = allClasses, 2 = allItems * @return the collection or set of the objects */ private Collection computeResult(int indexToCache, boolean callBeforeLookup) { Collection cachedResult = null; synchronized (proxy()) { Collection[] cc = getCache(); if (cc != null && cc != R.NO_CACHE) { cachedResult = cc[indexToCache]; } } // if caches exist, wait for finished Lookup.Result[] arr = myBeforeLookup(callBeforeLookup, cachedResult != null); // use caches, if they exist Collection[] cc; synchronized (proxy()) { cc = getCache(); if (cc != null && cc != R.NO_CACHE) { cachedResult = cc[indexToCache]; } } if (cachedResult != null) { return cachedResult; } if (indexToCache == 1) { return new LazySet(this, cc, indexToCache, callBeforeLookup, arr); } return new LazyList(this, cc, indexToCache, callBeforeLookup, arr); }
private void updateResultCache(Object[] oldCC, int indexToCache, Result[] arr, Collection<Object> ret) { synchronized (proxy()) { Collection[] cc = getCache(); if (cc != oldCC) { // don't change the cache when it is based on // outdated results return; } if (cc == null || cc == R.NO_CACHE) { // initialize the cache to indicate this result is in use setCache(cc = new Collection[3]); } if (arr == weakL.getResults()) { // updates the results, if the results have not been // changed during the computation of allInstances cc[indexToCache] = ret; } } } }
/** Computes results from proxied lookups. * @param indexToCache 0 = allInstances, 1 = allClasses, 2 = allItems * @return the collection or set of the objects */ private Collection computeResult(int indexToCache, boolean callBeforeLookup) { Collection cachedResult = null; synchronized (proxy()) { Collection[] cc = getCache(); if (cc != null && cc != R.NO_CACHE) { cachedResult = cc[indexToCache]; } } // if caches exist, wait for finished Lookup.Result[] arr = myBeforeLookup(callBeforeLookup, cachedResult != null); // use caches, if they exist Collection[] cc; synchronized (proxy()) { cc = getCache(); if (cc != null && cc != R.NO_CACHE) { cachedResult = cc[indexToCache]; } } if (cachedResult != null) { return cachedResult; } if (indexToCache == 1) { return new LazySet(this, cc, indexToCache, callBeforeLookup, arr); } return new LazyList(this, cc, indexToCache, callBeforeLookup, arr); }
private void updateResultCache(Object[] oldCC, int indexToCache, Result[] arr, Collection<Object> ret) { synchronized (proxy()) { Collection[] cc = getCache(); if (cc != oldCC) { // don't change the cache when it is based on // outdated results return; } if (cc == null || cc == R.NO_CACHE) { // initialize the cache to indicate this result is in use setCache(cc = new Collection[3]); } if (arr == weakL.getResults()) { // updates the results, if the results have not been // changed during the computation of allInstances cc[indexToCache] = ret; } } } }