private void finishCancelled(ClientContext context) { USKFetcherCallback[] cb; synchronized(this) { completed = true; cb = callbacks.toArray(new USKFetcherCallback[callbacks.size()]); } for(USKFetcherCallback c: cb) c.onCancelled(context); }
@Override public boolean run(ClientContext context) { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onCancelled(context); return false; }
@Override public void onCancelled(ClientContext context) { if(logMINOR) Logger.minor(this, "Cancelled on "+this); synchronized(this) { finished = true; } if(persistent) { // This can be called from USKFetcher, in which case we want to run on the // PersistentJobRunner. try { context.jobRunner.queue(new PersistentJob() { @Override public boolean run(ClientContext context) { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onCancelled(context); return false; } }, NativeThread.HIGH_PRIORITY); } catch (PersistenceDisabledException e) { // Impossible. } } else { if(callback instanceof USKFetcherTagCallback) ((USKFetcherTagCallback)callback).setTag(USKFetcherTag.this, context); callback.onCancelled(context); } }