Daniel Barlow <dan@...> writes:
> As Nikodemus points out, by using SETF you're setting the (global
> value of the) variable, not rebinding it. To bind it, use LET.
>
> Once you've bound it, any further setfs will affect only the local
> binding, so, yes, you have thread-local storage.
I think I'm getting straightened out on that point.
> > That then leads me to wonder how to create a shareable object such as
> > a hash table (or an a-list) that has serialized access from all the
> > threads that need to touch it in some way.
>
> Using a variable declared globally with DEFVAR or DEFPARAMETER, and
> a mutex to control access to it.
>
> ;; from memory; details probably wrong, but that's what apropos is for
> (defvar *foo* 1)
> (defvar *foo-lock* (make-mutex))
>
> (with-mutex (*foo-lock*)
> (incf *foo*)) ; or whatever
Yay! Examples!
Apropos has been helping me find out what exists. But documentation
and describe have not been helpful in what to do with it :-(
> In outline, anyway. Better threads docs is on my todo (aka my "yeah,
> right, like that'll ever happen") list
Heh. No one likes to document ;-)
In the meantime, is SBCL following any de facto standards for
functions, macros, and objects for threading? That is, is there a
place where I can look for some sort of tutorial on threaded
programming in Lisp in general that will work with SBCL?
I've resorted to looking through the source code now. I'm already
confused by what I assume are basic things like (in-package
"SB!THREAD") instead of (in-package "SB-THREAD") and not being able
to find an associated (make-package "SB!THREAD").
I could start working on documentation as I figure things out, but it
is almost certain to be full of lies, misdirection, and apocrypha.
Then again, it might just be flat out wrong.
Do macros even take documentation strings? The CLHS mentions
compiler-macro as a type, but I don't think that is the same thing.
* (documentation 'sb-thread:with-mutex 'function)
NIL
* (documentation 'sb-thread:with-mutex 'compiler-macro)
NIL
I know that sb-thread:with-mutex is a macro. Documentation doesn't
like it when I pass in 'macro.
BTW, has anyone looked at this:
http://www.caddr.com/macho/archives/sbcl-devel/2004-4/3337.html
I haven't seen a response to it. I was wondering if I need to provide
more information or if there is already a known problem with SMP
machines. I don't know if this problem will get in my way or not, nor
do I know what sort of priority threads have. Until I built SBCL on
it, I was running SBCL on my webserver only and that is a slow
machine. The SMP box is on my LAN which makes working on it more
convenient.
Thanks.
--
I wouldn't mind the rat race so much if it wasn't for all the damn cats.
|