2014-03-19 17:10 GMT+01:00 Yann Simon <yann.simon...@gmail.com>: > 2014-03-19 17:05 GMT+01:00 Rémy Maucherat <r...@apache.org>: > > 2014-03-19 16:36 GMT+01:00 Yann Simon <yann.simon...@gmail.com>: > > > >> I have maybe found another problem: > >> onAllDataRead is called with the same thread that is calling input.read. > >> > > > > I am not aware of any requirement that says this is not allowed. > > > > Rémy > > You're right, the specs is not precise for this. > But doing so makes the ReadListener very difficult to use: > the onAllDataRead is called even before we had a chance to make > something with the data we just read. >
This is because you're forking a thread, it won't concurrently invoke the two events (which would be invalid). > > I'd wish the specs to be much more precise for this sort of behavior, > because it is now quite impossible to write a ReadListener that can > run both on Jetty and Tomcat for example. > Other async APIs like NIO2 are not any more "precise" on purpose about the threading model, because this allows being flexible and have better performance. You could use a semaphore to implement your desired behavior. Rémy