/** * This method is used to flush all of the queued packets to * the client. This method will block not block but will simply * flush any data to the underlying transport. Internally the * data will be queued for delivery to the connected entity. */ public void flush() throws IOException { boolean done = writer.flush(); if(!done) { flusher.flush(); } }
/** * This is used to close the flusher ensuring that all of the * data within the writer will be flushed regardless of the * amount of data within the writer that needs to be written. If * the writer does not block then this waits to be finished. */ public synchronized void close() throws IOException { boolean ready = writer.flush(); if(!closed) { closed = true; } if(!ready) { scheduler.schedule(true); } }
/** * This is executed when the flusher is to write all of the data to * the underlying socket. In this situation the writes are attempted * in a non blocking way, if the task does not complete then this * will simply enqueue the writing task for OP_WRITE and leave the * method. This returns true if all the buffers are written. */ private synchronized void execute() throws IOException { boolean ready = writer.flush(); if(!ready) { boolean block = writer.isBlocking(); if(!block && !closed) { scheduler.release(); } scheduler.repeat(); } else{ scheduler.ready(); } }