Add optional name parameter to create-thread.
authorMatt Birkholz <matt@birchwood-abbey.net>
Fri, 1 Jun 2018 21:15:27 +0000 (14:15 -0700)
committerMatt Birkholz <matt@birchwood-abbey.net>
Tue, 5 Jun 2018 17:15:58 +0000 (10:15 -0700)
src/runtime/thread.scm

index 0ca02f92bc90d4497067467a255d7d1255142b97..4691a9a40fd397c8038c15f592de26b678bfbc5b 100644 (file)
@@ -210,7 +210,7 @@ USA.
   (guarantee thread? thread 'thread-execution-state)
   (thread/execution-state thread))
 
-(define (create-thread root-continuation thunk)
+(define (create-thread root-continuation thunk #!optional name)
   (if (not (or (not root-continuation) (continuation? root-continuation)))
       (error:wrong-type-argument root-continuation
                                 "continuation or #f"
@@ -226,6 +226,9 @@ USA.
              (call-with-current-continuation
                (lambda (continuation)
                  (let ((thread (make-thread continuation)))
+                   (if (not (default-object? name))
+                       (1d-table/put! (thread/properties thread)
+                                      'name name))
                    (%within-continuation (let ((k return)) (set! return #f) k)
                                          #t
                                          (lambda () thread)))))