/** * Load data via the proxy, and pump the records into the store * * @throws Exception */ public ObservableFuture<Void> load() throws Exception { if (lastLoadingFuture != null) { // cancel the old ones. lastLoadingFuture.cancel(); lastProxyLoadingFuture.cancel(); } // this might take a long time. // unfortunately i can't sync during it. // but this means that after a LOAD operation is requested, // any adds that someone does will be overridden by the proxy.load() return value. // note: unfortunately this is synchronous. lastProxyLoadingFuture = proxy.load(); lastLoadingFuture = new DefaultObservableFuture<Void>(this); // listen for completion of this future. lastProxyLoadingFuture.addObserver(onLoadCompleteCallback); // this whitespace might be all it takes to miss a callback, so we have to listen first, check // second. if (handleImmediatelyDone(lastProxyLoadingFuture, lastLoadingFuture)) { lastProxyLoadingFuture.removeObserver(onLoadCompleteCallback); } return lastLoadingFuture; }
public void copy() { if (realData == null) { realData = new RealData(idx); for (int i = 0; i < idx; i++) { realData.set(i, proxy.get(i)); } } }
public CopyWriteProxy(DataProxy dataProxy) { super(dataProxy.size()); this.proxy = dataProxy; }
@Override public int get(int idx) { return realData == null ? proxy.get(idx) : super.get(idx); }