Ian Bicking wrote:
> On Mon, 2003-07-28 at 10:32, Aaron Held wrote:
>> In the CVS version it looks like the the servlets are created for
>> each request.
> 
> I'm not sure if this was ever the behavior, though I always thought it
> was too.  ServletFactory.py:181 is where the caching is done.  The
> servlet *class* is cached, but the instances seem to be recreated
> each time. 
> 
> Hmmm... maybe it used to be that caching was done in Application.  I
> didn't notice that, but there was such a bundle of code I may have
> missed it, and then perhaps took that code out without noticing it.

Yes, it was in Application.  The cache (could also call it a pool) is just a
list that starts out empty.  When you want an instance you call list.pop()
and if it raises an IndexError than you know all servlets are in use and you
actually create a new instance.  When done with the instance you use
list.append() to return it to the pool.  list.append() and list.pop() are
atomic operations and therefore thread-safe with no need for locks.

Note that this code used to use a non-blocking Queue instead of a list, but
that caused a _very_ subtle timing-related bug.  The list code is faster,
and more importantly, works :-)  Basically, Queues are not really reliable
when used in non-blocking mode.  I can dig up more information if anyone is
interested.

> 
> If caching wasn't done in the factory, I think it should be.  I think
> that just means we have to have a method to return the servlet to the
> factory, and then the factory can keep a pool of servlets.

I agree -- the caching belongs in the factory, not in Application.

- Geoff


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Webware-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to