fork-join   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/core/xthread.xtm

Implementation

;; forka and join
(bind-func fork-join
  (lambda ()
    (letz ((i 0))
      (printout "Finish Order: ")
      (sync
       (dotimes (i 10)
         (spawn (let ((jj i)) ;; each closure needs it's own i!
                  (lambda ()
                    (thread_sleep (dtoi64 (* 5. (random))) 0)
                    (printout jj)))))
       1)
      (println)
      (println "Joined\n")
      void)))


Back to Index