[Small-cl-src] Re: simple locking retry
Joe Marshall
prunesquallor at comcast.net
Sun Jun 27 12:58:34 UTC 2004
Randall Randall <randall at randallsquared.com> writes:
> Second try; let's see if I get it right this time:
>
> This is intended to be a simple locking protocol for
> systems that need to be usable on both serve-event-only
> systems, like CMUCL on PPC, and more ordinary
> multi-processing systems. I'm currently using it as
> part of PSILISP, my webapp framework.
>
> This seems to work, and people I've run it by agree
> that it seems to work, but there could be some serious
> problem with it, so use at your own risk. I am only
> an egg.
>
> This code is released as public domain.
>
> (defmacro enqueue (queue)
> "Appends a unique ID to a queue."
> (let ((id (gensym)))
> `(let ((,id (gensym)))
> (setf ,queue (append ,queue (list ,id)))
> ,id)))
This isn't thread safe. If two processes attempted to enter the queue
simultaneously, one could get lost.
--
~jrm
More information about the Small-cl-src
mailing list