[armedbear-devel] Questions for use in a server

Alessio Stalla alessiostalla at gmail.com
Sat Jan 9 01:14:39 UTC 2010


On Sat, Jan 9, 2010 at 1:24 AM, Blake McBride <blake at mcbride.name> wrote:
> Greetings,
> I am considering using ABCL as an extension language to a Web server app I
> have.  I know the answer to many of the questions I have in choosing the
> correct extension language and ABCL seems to fit the bill well.  I do have
> some questions, however.
>
> 1.  Can ABCL run concurrently in multiple threads without any problems (I
> understand the ramifications in terms of my application code)?

It can, and to my knowledge, there are no known multithreading-related bugs.

> 2.  I would like to have some utility code which is loaded once and shared
> by all the ABCL threads.  Each thread can then run code that is independent
> (i.e. they can have the same function names with different definitions).
>  (Perhaps I'd have to use packages for this.)

Packages are probably the best choice. ABCL as a system is a
singleton: all the code is shared across all threads. You can't have
two copies of ABCL in the same JVM, or better - you can't have two
copies loaded by the same classloader.

> 3.  If I am running a lot of different threads will ABCL allow code to be
> GC'd when the thread ends (presuming no other thread is using that code)?

In principle, yes: code, i.e. functions, are Java objects. However, if
in one thread you evaluate, say, (defun f () 42), the function won't
go away when the thread ends, because a reference to it is kept
through the symbol F. In other words, packages and symbols are global,
not per-thread, and so is everything that is reachable from a symbol.
However, you can use a per-thread package and delete-package it when
the thread terminates, for example; in such a scenario, all code
installed by that thread will be garbage collected, as long as it's
not referenced by someone else.

> 4.  ABCL seems to have a somewhat heavy startup time.  This is okay for the
> first time, but I need the threads to start much faster (much less than half
> a second).

You can start ABCL only once; you don't have to launch it for each
thread, and actually you can't do that at all unless you use a fresh
ClassLoader for each thread. Just reuse the same ABCL instance: it
will automatically detect that it's being called from multiple threads
and have its own per-thread state.

I hope I have answered your questions.

Bye,
Alessio




More information about the armedbear-devel mailing list