Lisp HUG Maillist Archive

Probably stupid question about atomicity

I want to write something like this (this is not real code):

(defun silly ()
  (let ((log '()))
    (flet ((logger (it)
             (system:atomic-push it log)))
      (spawn-lots-of-threads :logger #'logger)
      log)))

But if I read 19.13.1 (http://www.lispworks.com/documentation/lw70/LW/html/lw-146.htm#pgfId-902388) it looks as if I am not allowed to do that: I think I need to do something like this:

(defun less-silly ()
  (let ((log (cons 'log '())))
    (flet ((logger (it)
             (system:atomic-push it (cdr log))))
      (spawn-lots-of-threads :logger #'logger)
      (cdr log))))                  

Is that right?

(basically what I'm trying to do is to write some code which does a bunch of array-bashing using several threads, while also constructing 'logs' of what has happened which then get printed for later plotting: I don't care about the ordering of the log entries, but I do care that they don't get lost).

--tim
           

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Probably stupid question about atomicity

Unable to parse email body. Email id is 13447

Updated at: 2020-12-10 08:33 UTC