At 08:38 PM 4/26/2001 +0200, Andres Tuells wrote:
>I have made some changes to webware to permit building servlets (and other
>that can be reused by all the threads (not needed create a new instance)
>The idea is to encapsulate the attributes in a thread safe form:
>def somemethod(self, bar):
> self.foo=bar #this is not thread safe
> this=self.this() #implemented in MixIn ThisAccess
> this.foo=bar #this is thread safe
>For general variables used by all the threads use self, for vars that follow
>the awake-sleep cicle use this.
>With this mail comes the files and examples, unzip in WebKit folder.
>Sorry for my english, but it's not my mother languaje. This is valid for the
It's obviously a neat technique for supporting multiple threads. However,
it requires servlet authors to learn another aspect of using WebKit (use of
"this") in return for getting WebKit to not create additional instances.
The motivation here, as you say in your docs, is that creating new
instances consumes time and memory. However,
* The time is mitigated by the fact that we cache the instances.
* The memory is mitigated by the fact that we only create the instances
when needed, which is when there are simultaneous requests.
Although WebKit is *supposed* to let you implement threadSafe() to return
1, so that you can bypass the instance creation and just keep dispatching
requests to the same servlet. However, I don't think we ever implemented that.
I don't see the issues being strong enough that we would introduce these
changes directly in WebKit and require servlet authors to use both "self"
There's a couple ways you could go from here:
You could restructure this as a ThisKit plug-in, that when loaded by WebKit
modifies it with your enhancements. Then anyone wanting to use "this"
approach (oooh! nice pun) could get Webware and your kit and do so. I
haven't looked at your code close enough to know how feasible this is. If
you need additional hooks in the existing WebKit classes in order to create
such a plug-in, we could talk about that.
Another approach would be to create a more generic ThisKit that wasn't
necessarily focused on WebKit and servlets, but still offered the mix-in
and basic concepts. You would then encourage people to use ThisKit for
unique objects in their application that must be used thread-safely from
those pesky servlets that will all run simultaneously. There will always be
a need for that, especially as applications start to grow in complexity.
Also, perhaps this technique is something that could be used in MiddleKit
as an option. I assume we could rework it so that "this" became "self"
through some kind of wrapper. Of course, wrappers have the isinstance()
<sidebar> <rant> But that problem wouldn't exist if isinstance() was a
method rather than another stupid global function which cuts objects out of
the loop when they need to do stuff like this. </rant> <soapbox> OO
languages should talk to objects via msgs, not functions. </soapbox> </sidebar>
Let us know what you plan to do next with "this".