[Mono-dev] Re: Patch for compiling HttpApplication for Grasshopper (without use of yield)

Miguel de Icaza miguel at novell.com
Sat Sep 24 12:49:35 EDT 2005


Hello,

> Attached is a patch to rewrite the 'Pipeline' & 'RunHooks' methods without the use of yield.
> The code is under '#if TARGET_JVM' and is meant for the Grasshopper configuration.
> Ben & Miguel - would you prefer having this patch as is (including the #if TARGET_J2EE) or
> is it acceptable that we will share the new code for Mono and remove the use of 'yield' from
> HttpApplication?

My preference is to keep the code on an HttpApplication.jvm.cs as the
patch is considerably large and the code which remains untouched is
merely a bunch of method accessors.   

>    * Tick didn't work as is in the TARGET_J2EE model. We don't manage our own thread pool for
>      ASP.Net (the J2EE servlet does this) and I replaced the 'if (pipeline.MoveNext ())'
>      with a 'while (pipeline.MoveNext ())'. I do not understand well enough how the Tick
>      ticks in Mono, especially where I see in Resume that it does not Tick if it's still
>      in the state of 'in_begin'.

This is a good observation: that particular piece of code is there to
deal with a special case: the begin invoke handler completing by the
time it returns to the caller.

We ran into this issue with a few http module handlers that registered
themselves with the async pattern, but were actually doing all the work
during the begin method invocation which means that the callback would
not have been invoked to kick the pipeline back into action. 

> Any comments on the class design and correctness of this rewrite are more then welcome.
> If you can elaborate more about 'Tick' and how it works in Mono it will help me to understand
> where the TARGET_J2EE behaves differently and find the correct solution for this (I see the
> use of 'while' as hack).

The trick about Tick is that it resumes the pipeline execution.  Without
async handlers its execution we would not need this, we would not need
it either if we were willing to keep a thread used while its waiting.

The idea is that when we start an async handler and the handler has
queued whatever it is that it wants to queue the thread is returned to
the pool instead of having it waiting.

The Tick routine is invoked when tasks are completed (it is actually
called from Resume).

Miguel.



More information about the Mono-devel-list mailing list