Again and again I meet this problem:
is there any way to synchronize two functions? I mean, for example, I need
to leave some function just after another function (say some event-handler)
was called. So the solution would be something like queues or semaphores.
But there isn't anything such in CL (or, at least, I did not find it).
It is - of course - possible to write it like this:
(defvar *done*)
(defun some-fn ()
(setf *done* nil)
(do-something)
(while (not *done*) (sleep 1)))
(defun event-handler ()
(setf *done* t))
But is there something more sophisticated? And, if even possible, something
implementation-independent? (And if not, then something using features
Franz ACL for Windows?)
Martin
In article <·······································@uran>,
Martin Volf (Wulf) <·····@sun.felk.cvut.cz> wrote:
>Again and again I meet this problem:
>is there any way to synchronize two functions? I mean, for example, I need
>to leave some function just after another function (say some event-handler)
>was called. So the solution would be something like queues or semaphores.
>But there isn't anything such in CL (or, at least, I did not find it).
Queues and semaphores are only necessary when you have multi-tasking.
Common Lisp doesn't have multi-tasking, so there's no need for such
facilities.
Some implementation have added multi-tasking extensions, and they generally
provide synchronization mechanisms to go along with them. There's no
standardization among any of this, though.
--
Barry Margolin, ······@bbnplanet.com
BBN Corporation, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Barry Margolin <······@bbnplanet.com> writes:
> In article <·······································@uran>,
> Martin Volf (Wulf) <·····@sun.felk.cvut.cz> wrote:
> >Again and again I meet this problem:
> >is there any way to synchronize two functions? I mean, for example, I need
> >to leave some function just after another function (say some event-handler)
> >was called. So the solution would be something like queues or semaphores.
> >But there isn't anything such in CL (or, at least, I did not find it).
>
> Queues and semaphores are only necessary when you have multi-tasking.
> Common Lisp doesn't have multi-tasking, so there's no need for such
> facilities.
> Some implementation have added multi-tasking extensions, and they generally
> provide synchronization mechanisms to go along with them. There's no
> standardization among any of this, though.
Although not in the Common LISP standard, there are LISP light weight
processes implemented in package mp. These adhere to a kind of
standard set up once by the Symbolics machines; the mp implementations
on LispWorks and Allegro are almost the same.
So, waiting for a semaphore to be released can be done e.g. with
(mp::process-wait-with-timeout)
Heiko