@SuppressWarnings({"unchecked"}) protected F create(E key) { long start = System.nanoTime(); F t = calculatable.calculate(owner, key); long end = System.nanoTime(); miss(end - start); save(key, t); return t; }
@Override @SuppressWarnings({"unchecked"}) public F getOrCreate(E o) { if (DependencyTracker.isBypassCaches()) { return calculatable.calculate(owner, o); } else { lock(o); try { Object v = load(o); if (v != UNDEFINED) { DependencyTracker.mark(getDependencyNode()); hit(); return (F) v; } DependencyNode callerNode = DependencyTracker.track(getDependencyNode()); try { while (true) { try { return create(o); } catch (ResourceOccupied e) { if (callerNode != null) { throw e; } else { unlock(o); try { e.getResource().waitForEndOfModification(); } finally { lock(o); } v = load(o); if (v != UNDEFINED) { hit(); return (F) v; } } } } } finally { DependencyTracker.exit(callerNode); } } finally { unlock(o); } } }
@Override public CacheDescriptor getDescriptor() { CacheId id = CalculatableHelper.getId(calculatable.getClass()); return CacheFactory.getProvider().getDescriptor(id); }