* enhancement: location of user or system initialization file can now easily
be customized for saved cores. See: SB-EXT:*USERINIT-PATHNAME-FUNCTION*
and SB-EXT:*SYSINIT-PATHNAME-FUNCTION*.
+ * enhancement: SB-EXT:MAKE-THREAD accepts an argument list designator for
+ the thunk, as a keyword argument, :arguments.
* bug fix: bound derivation for floating point operations is now more
careful about rounding possibly closing open bounds. (lp#793771)
* bug fix: SB-POSIX:SYSCALL-ERROR's argument is now optional. (accidental
;;;; The beef
-(defun make-thread (function &key name)
+(defun make-thread (function &key name arguments)
#!+sb-doc
- "Create a new thread of NAME that runs FUNCTION. When the function
+ "Create a new thread of NAME that runs FUNCTION with the argument
+list designator provided (defaults to no argument). When the function
returns the thread exits. The return values of FUNCTION are kept
around and can be retrieved by JOIN-THREAD."
- #!-sb-thread (declare (ignore function name))
+ #!-sb-thread (declare (ignore function name arguments))
#!-sb-thread (error "Not supported in unithread builds.")
+ #!+sb-thread (assert (or (atom arguments)
+ (null (cdr (last arguments))))
+ (arguments)
+ "Argument passed to ~S, ~S, is an improper list."
+ 'make-thread arguments)
#!+sb-thread
(let* ((thread (%make-thread :name name))
(setup-sem (make-semaphore :name "Thread setup semaphore"))
(real-function (coerce function 'function))
+ (arguments (if (listp arguments)
+ arguments
+ (list arguments)))
(initial-function
(named-lambda initial-thread-function ()
;; In time we'll move some of the binding presently done in C
(setf (thread-result thread)
(cons t
(multiple-value-list
- (funcall real-function))))
+ (apply real-function arguments))))
;; Try to block deferrables. An
;; interrupt may unwind it, but for a
;; normal exit it prevents interrupt
(sb-thread:thread-deadlock ()
:deadlock))))
(assert (eq :ok (join-thread t1)))))
+
+#+sb-thread
+(with-test (:name :pass-arguments-to-thread)
+ (assert (= 3 (join-thread (make-thread #'+ :arguments '(1 2))))))
+
+#+sb-thread
+(with-test (:name :pass-atom-to-thread)
+ (assert (= 1/2 (join-thread (make-thread #'/ :arguments 2)))))
+
+#+sb-thread
+(with-test (:name :pass-nil-to-thread)
+ (assert (= 1 (join-thread (make-thread #'* :arguments '())))))
+
+#+sb-thread
+(with-test (:name :pass-nothing-to-thread)
+ (assert (= 1 (join-thread (make-thread #'*)))))
+
+#+sb-thread
+(with-test (:name :pass-improper-list-to-thread)
+ (multiple-value-bind (value error)
+ (ignore-errors (make-thread #'+ :arguments '(1 . 1)))
+ (when value
+ (join-thread value))
+ (assert (and (null value)
+ error))))