/** * Closes the pipe. No more data will be allowed to be written to this Pipe's WriteHead. Any * blocked {@link DataPipe.Source#readAll()} will return whatever data they can, and other * blocked {@link DataPipe.Source#read()} will immediately return null following this call even * if they cannot get data (these two processes still happen in fair order). All subsequent * reads (blocking or nonblocking) will either return data immediately as long as any is still * buffered in the pipe, and then forevermore immediately return null once all buffered data is * depleted. */ public void close() { lockWrite(); try { $gate.close(); } finally { unlockWrite(); } X.notifyAll($gate); // trigger the return of any final readAll calls // give our listener a chance to notice our closure. invokeListener($el); }