A callback abstraction that handles completed/failed events of asynchronous operations.
Semantically this is equivalent to an optimise Promise<Void>, but callback is a more meaningful name than EmptyPromise
485486487488489490491492493494495
} @Override void onEnter(final AbstractConnection connection) { Callback callback=new Callback() { @Override public void succeeded() { while(true)
509510511512513514515516517518519
if (request.isAsyncSupported() && min_async_size>0 && resource.length()>=min_async_size) { final AsyncContext async = request.startAsync(); Callback callback = new Callback() { @Override public void succeeded() { async.complete();
535536537538539540541542543544545
* @param content The content to send * @param callback The callback to use to notify success or failure */ public void sendContent(ByteBuffer content, final Callback callback) { write(content,true,new Callback() { @Override public void succeeded() { closed();
456457458459460461462463464465466
757677787980818283
/* ------------------------------------------------------------ */ /** Call to signal that a read is now possible. */ public void fillable() { Callback callback=_interested.get(); if (callback!=null && _interested.compareAndSet(callback,null)) callback.succeeded(); }
949596979899100101102
/* ------------------------------------------------------------ */ /** Call to signal a failure to a registered interest */ public void onFail(Throwable cause) { Callback callback=_interested.get(); if (callback!=null && _interested.compareAndSet(callback,null)) callback.failed(cause); }
102103104105106107108109110
} /* ------------------------------------------------------------ */ public void onClose() { Callback callback=_interested.get(); if (callback!=null && _interested.compareAndSet(callback,null)) callback.failed(new ClosedChannelException()); }
869870871872873874875876877878879
// write the content asynchronously if supported if (request.isAsyncSupported()) { final AsyncContext context = request.startAsync(); ((HttpOutput)out).sendContent(content,new Callback() { @Override public void succeeded() { context.complete();
707708709710711712713714715716717
if (info==null) info = _response.newResponseInfo(); // wrap callback to process 100 or 500 responses final int status=info.getStatus(); final Callback committed = (status<200&&status>=100)?new Commit100Callback(callback):new CommitCallback(callback); // committing write _transport.send(info, content, complete, committed); } else if (info==null)
803804805806807808809810811812813
_response.getHttpOutput().closed(); } else { LOG.warn("Commit failed",x); _transport.send(HttpGenerator.RESPONSE_500_INFO,null,true,new Callback() { @Override public void succeeded() { _callback.failed(x);