/*
@see javax.servlet.ServletResponse#flushBuffer()
550553
@Override
    public void flushBuffer() throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Flushing buffers: " + this);
        }
        if (null != this.outWriter) {
            this.outWriter.flush();
        } else {
            this.outStream.flush();
        }
    }
328510
private void refreshBuffer() throws IOException {
    if (output == null) {
      // We're writing to a single buffer.
      throw new OutOfSpaceException();
    }

    // Since we have an output stream, this is our buffer
    // and buffer offset == 0
    output.write(buffer, 0, position);
    position = 0;
  }
314736
void flushCache() throws Exception {
		if (!entryCache.isEmpty()) {
			entries.putAll(entryCache);
			entryCache.clear();
		}
		if (!eventsBufferCache.isEmpty()) {
			eventsBuffer.putAll(eventsBufferCache);
			eventsBufferCache.clear();
		}
	}
284772
protected synchronized void flushBuffer(boolean chunkComplete,
      boolean keepPartialData) throws IOException {
    if (count != 0) {
      int chunkLen = count;
      count = 0;
      writeChecksumChunk(buf, 0, chunkLen, keepPartialData && !chunkComplete);
      if (!chunkComplete) {
        if (!keepPartialData) {
          bytesSentInChunk += chunkLen;
        } else {
          count = chunkLen;
        }
      } else {
        bytesSentInChunk = 0;
      }
    }
  }
694805
@Override
  public void flush()
  {
    // server/021g
    _logWriterQueue.wake();
    
    waitForFlush(10);
    
    try {
      super.flush();
    } catch (IOException e) {
      log.log(Level.FINER, e.toString(), e);
    }
  }
1203632
private void flushBuffer() {
		// Do the actual logging:
		removes.ensureCapacity(buffer.size());
		for(Iterator<LoggingEvent> i = buffer.iterator(); i.hasNext();) {
			try {
				LoggingEvent event = (LoggingEvent)i.next();
				doLog(event);
				removes.add(event);
			} catch(Exception e) {
				errorHandler.error("Failed to flush log", e, ErrorCode.FLUSH_FAILURE);
			}
		}

		// Remove from the buffer any events that were reported:
		buffer.removeAll(removes);

		// Clear the buffer of reported events:
		removes.clear();
	}
1053685
protected void flush() throws IOException {
		if (this.tempStream != null && this.buffer.position() > 0) {
			final int pos = this.buffer.position();
			this.buffer.rewind();
			this.buffer.limit(pos);

			this.tempStream.write(this.buffer);

			this.buffer.rewind();
			this.buffer.limit(this.buffer.capacity());

			this.bufferPosition += pos;
		}
	}
913448
@Override
    protected boolean checkBuffer() throws IOException {
        if (null != this.buffer) {
            if (this.buffer.hasRemaining()) {
                return true;
            }
            this.buffer.release();
            this.buffer = null;
        }
        return setNextBuffer();
    }
1017779
public void flush() {
        logger.info(String.format("(%s) Flush, buffer size: %d", detectorImpl.getName(), queue.size()));
        while(queue.size()>0)
            detectorImpl.fireEvent(queue.poll());
    }
1222853
def flush(self):
        '''
        
        '''
        # return if empty
        if self.__bufferidx == 0:
            return 
        # send here the data
        self.conn.send("%s\r\n" % hex(self.__bufferidx)[2:])
        self.conn.send("%s\r\n" % ''.join(self.__buffer[0:self.__bufferidx]))
        # reset buffer index = 0 (beginning of the buffer)
        self.__bufferidx = 0
743096
protected final void flushWriter() throws org.xml.sax.SAXException
    {
        final java.io.Writer writer = m_writer;
        if (null != writer)
        {
            try
            {
                if (writer instanceof WriterToUTF8Buffered)
                {
                    if (m_shouldFlush)
                         ((WriterToUTF8Buffered) writer).flush();
                    else
                         ((WriterToUTF8Buffered) writer).flushBuffer();
                }
                if (writer instanceof WriterToASCI)
                {
                    if (m_shouldFlush)
                        writer.flush();
                }
                else
                {
                    // Flush always. 
                    // Not a great thing if the writer was created 
                    // by this class, but don't have a choice.
                    writer.flush();
                }
            }
            catch (IOException ioe)
            {
                throw new org.xml.sax.SAXException(ioe);
            }
        }
    }
446410
@Override
    public void flush() {
        // in-memory - do nothing
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, "flush", "");
        }
    }
843867
public void flush() throws IOException {
        checkForClosed();
        writeBufferToFile();
        if (_currentOffset > _offset) { // something to commit
            _nfsFile.commit(_offset, (int) (_currentOffset - _offset));
            _offset = _currentOffset;
        }
        super.flush();
    }
365153
def flush(self):
        
        # Flush buffer
        line = self._buffer.getvalue()
        self._buffer = StringIO()

        # Send the message
        content = {"session_id": self._session, "text": line}
        self._herald.fire(self._peer, beans.Message(MSG_CLIENT_PRINT, content))
1319800
void flush(OutputStream out, String encoding)
         throws IOException
    {
        flush(new OutputStreamWriter(out,encoding));
    }
284935
public void flush() {
    lock.writeLock().lock();
    try {
      OMMapBufferEntry entry;
      for (Iterator<OMMapBufferEntry> it = bufferPoolLRU.iterator(); it.hasNext();) {
        entry = it.next();
        if (entry.file != null && entry.file.isClosed()) {
          if (removeEntry(entry))
            it.remove();
        }
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
618410
public final void flush() {
        int totalBytes = 0;
        int amountToPoll = outgoingPackets.size();
        
        Packet packet;

        boolean shouldEncrypt = encryption != null;
        
        var queue = new ArrayDeque<byte[]>();

        while (amountToPoll-- > 0 && (packet = outgoingPackets.poll()) != null) {
            int currentBytes = totalBytes;

            boolean tooBig = (totalBytes += packet.getSize(this)) >= bufferSize;
            boolean empty = outgoingPackets.isEmpty();

            if (!tooBig || empty) {
                queue.addAll(packet.getQueue());
            }

            // If we've buffered all of the packets that we can, send them off.
            if (tooBig || empty) {
                var raw = DIRECT_BUFFER_POOL.take(empty ? totalBytes : currentBytes);
                
                byte[] input;
                
                try {
                    while ((input = queue.pollFirst()) != null) {
                        raw.put(shouldEncrypt ? encryption.doFinal(input) : input);
                    }
                } catch (Exception e) {
                    throw new IllegalStateException("An exception occurred whilst encrypting data:", e);
                }
                
                raw.flip();
                
                queue.addAll(packet.getQueue());
                
                // It is important to synchronize on the packetsToFlush here, as we don't want the callback to
                // complete before the packet is queued.
                synchronized (packetsToFlush) {
                    if (!writing.getAndSet(true)) {
                        channel.write(raw, new Tuple<>(this, raw), PACKET_HANDLER);
                    } else {
                        packetsToFlush.offerFirst(raw);
                    }
                }

                totalBytes = packet.getSize(this);
            }
        }
    }