Page 1 of 1

Accessing the result of a Bordeaux Thread bt:make-thread cal

PostPosted: Wed Mar 13, 2019 11:10 pm
by lamseydaivy
In SBCL, how can you access the RESULT slot of a completed thread? The slot-value of an instance does not seem to work:

* (defparameter th (bt:make-thread (lambda () (LOOP FOR I FROM 1 TO 1000000 SUM (* I I)))))
TH
* (describe th)
#<SB-THREAD:THREAD "Anonymous thread" FINISHED values: 333333833333500000 {1005C0A183}>
[structure-object]

Slots with :INSTANCE allocation:
NAME = "Anonymous thread"
%ALIVE-P = NIL
%EPHEMERAL-P = NIL
OS-THREAD = 18446744073709551615
PRIMITIVE-THREAD = 62332928
INTERRUPTIONS = NIL
RESULT = (333333833333500000)
INTERRUPTIONS-LOCK = #<SB-THREAD:MUTEX "thread interruptions lock" (free)>
RESULT-LOCK = #<SB-THREAD:MUTEX "thread result lock" (free)>
WAITING-FOR = NIL
* (slot-value th 'result)

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {10012E0613}>:
When attempting to read the slot's value (slot-value), the slot RESULT is
missing from the object

Re: Accessing the result of a Bordeaux Thread bt:make-thread

PostPosted: Sat Mar 16, 2019 5:54 am
by pjstirling
Try JOIN-THREAD