Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bordeaux threads return value

76 views
Skip to first unread message

Jim Newton

unread,
Sep 27, 2016, 3:56:41 AM9/27/16
to
I'm looking at the documentation https://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation
And I see that I can start a thread with make-thread given a 0-ary function,
and I can wait on the thread with join-thread. But the documentation does not say how
to get the return value of the 0-ary function. I would have expected that join-thread would
return the value, but the documentation explicitly does not say that.

There does not seem to be a documented way in this version of the API to get the return value.
Can someone help?

Thanks
Jim

Jim Newton

unread,
Sep 27, 2016, 3:59:10 AM9/27/16
to
> But the documentation does not say how
> to get the return value of the 0-ary function.

It does seem that the sbcl implementation of join-thread returns the value of the function.

;;;; sbcl -----
(defun join-thread (thread)
(sb-thread:join-thread thread))

Nicolas Neuss

unread,
Sep 27, 2016, 4:20:40 AM9/27/16
to
Usually these threads will work on some shared datastructure where
access is controlled via mutices etc.

If you want to distribute calculations depending on parameters and
obtain the return values, take a look at lparallel which provides a nice
interface for that: pmap, precuce etc.

Nicolas

Jim Newton

unread,
Sep 27, 2016, 5:33:23 AM9/27/16
to
I took a look at the implementation of join-thread on several lisp implementations (sbcl, cmicl, ecl), and in each case join-thread returns the value which the 0-ary function returns. My suspicion is that that is the intent. It's just omitted from the documentation.

Nicolas Neuss

unread,
Sep 27, 2016, 6:49:59 AM9/27/16
to
Yes, and in my version of the SBCL manual it is documented:

Function: join-thread [sb-thread] thread &key default timeout

Suspend current thread until thread exits. Return the result values of the thread function.
[...]

Nevertheless, you should take a look at lparallel.

Nicolas

Jim Newton

unread,
Sep 27, 2016, 6:50:53 AM9/27/16
to


For example, the lipspworks version very explicitly returns the return value(s) of the function.

;; lispworks
(defun join-thread (thread)
(%join-thread thread)
(let ((return-values
(mp:process-property 'return-values thread)))
(values-list return-values)))
0 new messages