[ 
https://issues.apache.org/jira/browse/HTTPCORE-148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sam Berlin updated HTTPCORE-148:
--------------------------------

    Attachment: changes.txt

Alright -- suppose that'd be dreaming to hope implementations do it right. :)

Your approach should work fine.  I spent a little time working a different 
approach (one that we heavily use in LimeWire's NIO layer) that exposes an 
Executor to run events in the right I/O thread.  I tried a few different 
approaches to make it work in the httpnio architecture, and think this one 
works very well.  The end result is basically that IOSession & IOControl have a 
new 'Executor getIOExecutor' method, from which Runnables can be submitted.  
AbstractIOReactor has an internal Executor that it passes to IOSessionImpl and 
the events are added/polled from a Queue.

It lets all kinds of interesting things happen, without needing to maintain 
state.  For example, this Trigger problem could be implemented by saying:

 Trigger {
    submitResponse(HttpResponse response) {
          conn.getIOExecutor().execute(new Runnable() {
                public void run() {
                     submitResponse(request, response);
                }
          });
    }
 }

Eventually, if you find a need, things can get even fancier by exposing a 
ScheduledExecutorService & using a DelayQueue internally.  (We do this for all 
kinds of things, like buffering outgoing data for a short period of time, to 
reduce the number of outgoing TCP packets.)

> Create AsyncNHttpServiceHandler & AsyncNHttpClientHandler
> ---------------------------------------------------------
>
>                 Key: HTTPCORE-148
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-148
>             Project: HttpComponents HttpCore
>          Issue Type: New Feature
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta1
>            Reporter: Sam Berlin
>            Assignee: Oleg Kalnichevski
>             Fix For: 4.0-beta2
>
>         Attachments: changes.txt, changes.txt, changes.txt, changes2.txt
>
>
> Attached is a patch for AsyncNHttpServiceHandler.  It actually works (as 
> tested by running & hitting it with IE.)  :)
> To test, run the example 'AsyncNHttpFileServer' in the examples directory or 
> the TestAsyncNHttpHandlers test.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to