Callback called by the writer thread when it goes away.
195403
protected synchronized void writerDidExit ()
    {
        // clear out our writer reference
        _writer = null;
        log.debug("Writer thread exited.");

        // let the client observers know that we're logged off
        notifyClientObservers(new ObserverOps.Session(_client) {
            @Override protected void notify (SessionObserver obs) {
                obs.clientDidLogoff(_client);
            }
        });

        // now that the writer thread has gone away, we can safely close our socket and let the
        // client know that the logoff process has completed
        closeChannel();

        // let the client know when we finally go away
        if (_reader == null) {
            clientCleanup(_logonError);
        }
    }
356484
def close(self):
        """"""
        if self._poll is None:
            return
        self._poll.close()
        self._poll = None
        self._readers = 0
        self._writers = 0
        self._events = 0
        clear_callbacks(self)
469702
public void endRead() {
		SynchronizationPoint<NoException> sp;
		synchronized (this) {
			// if others are still reading, nothing to do
			if (--readers > 0) return;
			// if nobody is waiting to write, nothing to do
			if (writersWaiting == null) return;
			sp = writersWaiting.removeFirst();
			if (writersWaiting.isEmpty()) writersWaiting = null;
			writer = true;
		}
		sp.unblock();
	}
529286
protected void threadEnd() {
        //
        // Note the 'afterCallbacks' list is not going to have a well-defined order, so it is of limited use.
        // We probably want to revisit this with some kind of priority/order based on ranking to make
        // it more useful.
        //
        // At the moment we treat the setting of the tran timeout separately, rather than as a IJobExecutionEndCallbackService,
        // to reflect the fact that this is provided by a required dependency.  If we were to want this to function in SE mode,
        // say, we might want to factor this too as an "extension" that is provided by another layer, and so incorporate this into a
        // more generic, extensible "after" processing.
        try {
            getBatchKernel().workUnitCompleted(this);
        } catch (Exception e) {
            // FFDC instrumentation
        }

        if (afterCallbacks != null) {
            for (IJobExecutionEndCallbackService callback : afterCallbacks) {
                try {
                    if (logger.isLoggable(Level.FINER)) {
                        logger.logp(Level.FINER, CLASSNAME, "threadEnd", "Calling after callback", callback);
                    }
                    callback.jobEnded(runtimeWorkUnitExecution);
                } catch (Throwable t) {
                    // FFDC instrumentation
                }
            }
        }

        try {
            tranMgr.setTransactionTimeout(0);
        } catch (SystemException e) {
            // FFDC instrumentation
        }
    }
849075
public synchronized void losePrimacy() throws IOException {
    Preconditions.checkState(mState == State.PRIMARY, "unexpected state " + mState);
    Preconditions.checkState(mWriter != null, "writer thread must not be null in primary mode");
    Preconditions.checkState(mTailerThread == null, "tailer thread must be null in primary mode");
    mWriter.close();
    mWriter = null;
    mAsyncWriter = null;
    mMaster.resetState();
    mTailerThread = new UfsJournalCheckpointThread(mMaster, this);
    mTailerThread.start();
    mState = State.SECONDARY;
  }
803104
public void close() {
        lock.lock();
        try {
            if (writeTarget == null) {
                closePending = true;
                return;
            }
        } finally {
            lock.unlock();
        }
        writeTarget.closeConnection();
    }
569090
public synchronized void stop() {
    if (!mStopped) {
      mLoggingWorkerThread.interrupt();
      try {
        mLoggingWorkerThread.join();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      } finally {
        mStopped = true;
        mLoggingWorkerThread = null;
        LOG.info("AsyncUserAccessAuditLogWriter thread stopped.");
      }
    }
  }
355383
def disconnect(self):
        ""
        self._parser.on_disconnect()
        try:
            self._writer.close()
        except Exception:
            pass
        self._reader = None
        self._writer = None
641921
def close(self):
        
        if self._writable and not self._is_raw_of_buffered and not self._closed:
            self._closed = True
            if self._write_buffer:
                self.flush()
770897
@GuardedBy("evictionLock")
    void drainWriteBuffer() {
        for (int i = 0; i < WRITE_BUFFER_DRAIN_THRESHOLD; i++) {
            final Runnable task = writeBuffer.poll();
            if (task == null) {
                break;
            }
            task.run();
        }
    }
229527
public synchronized final void shutdown()
	{
		if (!this.isClosed) {
			this.isClosed = true;

			// close writing and reading threads with best effort and log problems
			
			// --------------------------------- writer shutdown ----------------------------------			
			for (int i = 0; i < this.readers.length; i++) {
				try {
					this.writers[i].shutdown();
				}
				catch (Throwable t) {
					LOG.error("Error while shutting down IO Manager writer thread.", t);
				}
			}

			// --------------------------------- reader shutdown ----------------------------------
			for (int i = 0; i < this.readers.length; i++) {
				try {
					this.readers[i].shutdown();
				}
				catch (Throwable t) {
					LOG.error("Error while shutting down IO Manager reader thread.", t);
				}
			}
			
			// ------------------------ wait until shutdown is complete ---------------------------
			try {
				for (int i = 0; i < this.readers.length; i++) {
					this.writers[i].join();
				}
				for (int i = 0; i < this.readers.length; i++) {
					this.readers[i].join();
				}
			}
			catch (InterruptedException iex) {}
		}
	}
148707
private void endWaitingForUsage() {
        synchronized (permanentUserReadWriteLock) {
            if (permissionWithoutUsageLimit != null)
                permissionWithoutUsageLimit = null;
            if (permissionWithoutUsageCloseThread != null) {
                permissionWithoutUsageCloseThread.cancel(true);
                permissionWithoutUsageLimit = null;
            }
        }
    }
207193
def close(self):
        
        if self.is_closing():
            return

        self._closing = True
        # make sure the writer wakes up
        self._can_write.set()
1230008
@Handler(priority = -1000)
    public void onStop(Stop event) throws InterruptedException {
        while (!inputWriters.isEmpty()) {
            Writer handler = inputWriters.entrySet().iterator().next()
                .getValue();
            handler.close(event);
        }
        while (!outputWriters.isEmpty()) {
            Writer handler = outputWriters.entrySet().iterator().next()
                .getValue();
            handler.close(event);
        }
    }
934947
def finalize(self):
        
        super(StringWriterConsumer, self).finalize()
        self.result = self.decoder(self.result)
1064835
def release(self):
        
        self.monitor.acquire()
        if self.rwlock < 0:
            self.rwlock = 0
        else:
            self.rwlock -= 1
        wake_writers = self.writers_waiting and self.rwlock == 0
        wake_readers = self.writers_waiting == 0
        self.monitor.release()
        if wake_writers:
            self.writers_ok.acquire()
            self.writers_ok.notify()
            self.writers_ok.release()
        elif wake_readers:
            self.readers_ok.acquire()
            self.readers_ok.notifyAll()
            self.readers_ok.release()
14497
public void close(String line, DispatchCallback callback) {
    // close file writer
    if (sqlLine.getRecordOutputFile() != null) {
      // instead of line could be any string
      stopRecording(line, callback);
    }

    DatabaseConnection databaseConnection = sqlLine.getDatabaseConnection();
    if (databaseConnection == null) {
      callback.setToFailure();
      return;
    }

    try {
      Connection connection = databaseConnection.getConnection();
      if (connection != null && !connection.isClosed()) {
        sqlLine.info(
            sqlLine.loc("closing", connection.getClass().getName()));
        connection.close();
      } else {
        sqlLine.info(sqlLine.loc("already-closed"));
      }
    } catch (Exception e) {
      callback.setToFailure();
      sqlLine.error(e);
      return;
    }

    sqlLine.getDatabaseConnections().remove();
    callback.setToSuccess();
  }