<commit_before>package org.eclipse.jetty.io;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.WritePendingException;
import java.util.ConcurrentModificationException;
import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;


/* ------------------------------------------------------------ */
/** 
 * A Utility class to help implement {@link AsyncEndPoint#write(Object, Callback, ByteBuffer...)}
 * by calling {@link EndPoint#flush(ByteBuffer...)} until all content is written.
 * The abstract method {@link #registerFlushInterest()} is called when not all content has been 
 * written after a call to flush and should organise for the {@link #completeWrite()}
 * method to be called when a subsequent call to flush should be able to make more progress.
 * 
 */
abstract public class WriteFlusher
{
    private final static ByteBuffer[] NO_BUFFERS= new ByteBuffer[0];
    private final AtomicBoolean _writing = new AtomicBoolean(false);
    private final EndPoint _endp;
    
    private ByteBuffer[] _buffers;
    private Object _context;
    private Callback _callback;
    
    protected WriteFlusher(EndPoint endp)
    {
        _endp=endp;
    }

    /* ------------------------------------------------------------ */
    public void write(Object context, Callback callback, ByteBuffer... buffers)
    {<commit_msg>jetty-9 WriteFlusher cleanup<commit_after>package org.eclipse.jetty.io;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.WritePendingException;
import java.util.ConcurrentModificationException;
import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;


/* ------------------------------------------------------------ */
/** 
 * A Utility class to help implement {@link AsyncEndPoint#write(Object, Callback, ByteBuffer...)}
 * by calling {@link EndPoint#flush(ByteBuffer...)} until all content is written.
 * The abstract method {@link #registerFlushInterest()} is called when not all content has been 
 * written after a call to flush and should organise for the {@link #completeWrite()}
 * method to be called when a subsequent call to flush should be able to make more progress.
 * 
 */
abstract public class WriteFlusher
{
    private final static ByteBuffer[] NO_BUFFERS= new ByteBuffer[0];
    private final AtomicBoolean _writing = new AtomicBoolean(false);
    private final EndPoint _endp;
    
    private ByteBuffer[] _buffers;
    private Object _context;
    private Callback _callback;
    
    protected WriteFlusher(EndPoint endp)
    {
        _endp=endp;
    }

    /* ------------------------------------------------------------ */
    public <C> void write(C context, Callback<C> callback, ByteBuffer... buffers)
    {
        if (callback==null)
            throw new IllegalArgumentException();
{'fraction_non_alphanumeric': 0.16322517207472959, 'fraction_numerical': 0.0009832841691248771, 'mean_word_length': 2.815, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6270669', 'n_tokens_mistral': 785, 'n_tokens_neox': 775, 'n_words': 252}