This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: krl servlets
- From: Per Bothner <per at bothner dot com>
- To: 62945 <62945 at bol dot com dot br>
- Cc: kawa <kawa at sources dot redhat dot com>
- Date: Mon, 31 May 2004 02:39:05 -0700
- Subject: Re: krl servlets
- References: <HYJICM$129B1E89C98DAD2B50E4037B3B16D6CE@bol.com.br>
62945 wrote:
- I have two (krl) servlets accessing the same *static*
module through "require". There seems to be a problem
since both don't work at the same time. The first
servlet to be invoked keeps working fine but the other
doesn't. If the container is restarted and the second is
called first it works ok but now the first servlet
breaks. I suppose this has to do with the registration
of the module. The docs say there can only be one
instance of a static one. So this means the module can't
be shared, right ...
It depends what is in the static module. If it is just procedure
definitions and other constants I don't see why it can't be shared.
There are some issues with environments and symbols - they're not
fully thread safe (this needs to be fixed) - but I think it is very
unlikely you'd run into this.
- are procedure closures thread safe ?
Yes.
Consider
...
(define (st)
(let ((x 0))
(let ((inc (lambda () (set! x (+ x 1))))
(dec (lambda () (set! x (- x 1)))))
(lambda (op)
(case op
((inc) (inc) x)
((dec) (dec) x)
(else #f))))))
(define s0 (st))
...
I wonder if (s0 'inc) (s0 'dec) will work correctly for
a servlet called by different clients.
That would not be thread safe, since they share the same
'x' variable. Of course you could add synchronization.
What about defining "st" in a (static) module and
requiring it by other modules.
That should be safe.
It all depends on what youy're trying to do.
--
--Per Bothner
per@bothner.com http://per.bothner.com/