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

Discussion of Common Lisp

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

Postby lamseydaivy » Wed Mar 13, 2019 11:10 pm

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
lamseydaivy
 
Posts: 1
Joined: Wed Mar 13, 2019 10:41 pm

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

Postby pjstirling » Sat Mar 16, 2019 5:54 am

Try JOIN-THREAD
pjstirling
 
Posts: 164
Joined: Sun Nov 28, 2010 4:21 pm


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 7 guests

cron