Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] ServletOutputStream.write in async mode

Hi all

In async mode servlet output stream write method receives a buffer and copies it to _aggregate buffer or schedules write job. However in the second case there is no way to detect if I can use the buffer again as there is no async write task callback (except flush that is not an option in fact). The other possible solution is to check isReady() after write operation to get onWritePossible() callback every time but it looks slightly weird and looks like this:

bufferLocked = true
if (stream.isReady) {
    stream.write(buffer, 0, size)
    if (stream.isReady) {
        // mark buffer is free and ready for reuse
        bufferLocked = false
    }
}

From the specification it's not exactly clear what is a lifecycle of a buffer provided to write method. Am I missing something?


Back to the top