/** * Mark the handle as disposed, and set it as LOST in case the current state is not final. * * This method should be called only when there's a reasonable expectation that the communication * with the child application is not needed anymore, either because the code managing the handle * has said so, or because the child application is finished. */ synchronized void dispose() { if (!isDisposed()) { // First wait for all data from the connection to be read. Then unregister the handle. // Otherwise, unregistering might cause the server to be stopped and all child connections // to be closed. if (connection != null) { try { connection.waitForClose(); } catch (IOException ioe) { // no-op. } } server.unregister(this); // Set state to LOST if not yet final. setState(State.LOST, false); this.disposed = true; } }
/** * Mark the handle as disposed, and set it as LOST in case the current state is not final. * * This method should be called only when there's a reasonable expectation that the communication * with the child application is not needed anymore, either because the code managing the handle * has said so, or because the child application is finished. */ synchronized void dispose() { if (!isDisposed()) { // First wait for all data from the connection to be read. Then unregister the handle. // Otherwise, unregistering might cause the server to be stopped and all child connections // to be closed. if (connection != null) { try { connection.waitForClose(); } catch (IOException ioe) { // no-op. } } server.unregister(this); // Set state to LOST if not yet final. setState(State.LOST, false); this.disposed = true; } }