jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: [servlet-spec users] Re: Re: Re: NIO specification clarification

From: Mark Thomas <markt_at_apache.org>
Date: Tue, 30 Apr 2013 17:26:06 +0100

On 30/04/2013 15:33, Rémy Maucherat wrote:
> On 04/30/2013 12:21 PM, Mark Thomas wrote:

>> My question with auto blocking is how does the Servlet container know
>> if a read or write is meant to be blocking or not? The user code (the
>> WebSocket implementation) knows but there is no API that enables it to
>> tell the container. I had originally thought that flush() could be
>> used to do this (i.e. block if flush() is called) but as you pointed
>> out, that might work in an HTTP upgrade scenario but not in a Servlet
>> one. Using flush(0 in this way would work for WebSocket since it used
>> HTTp upgrade but having the same method behave differently for HTYTP
>> Upgrade and async servlets doesn't seem right either.

> It should be possible to make the decision about blocking or not by
> using isReady. If isReady is used when doing the reads/writes, it will
> not block. If isReady is not used, and things occurs inside a container
> thread, it blocks (I never thought it would be a good idea to block an
> async thread).

Ah. That sounds like it might work. I'll see if I can find some time to
experiment.

Mark