1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-23 03:37:40 +00:00

Pass thread body explicitly in thread/new.

Doing it via thread/send make sense, but is a bit
strange. Passing the body explicitly will make more
sense to API users.
This commit is contained in:
Calvin Rose
2019-12-18 15:07:46 -05:00
parent b9f0f14e31
commit 6a39c4b91d
2 changed files with 14 additions and 10 deletions

View File

@@ -10,8 +10,7 @@
(defn make-worker
[name interval]
(-> (thread/new)
(:send worker-main)
(-> (thread/new worker-main)
(:send name)
(:send interval)))
@@ -39,8 +38,7 @@
(if (< depth 5)
(do
(defn subtree []
(-> (thread/new)
(:send worker-tree)
(-> (thread/new worker-tree)
(:send (string name "/" (choose "bob" "marley" "harry" "suki" "anna" "yu")))
(:send (inc depth))))
(let [l (subtree)
@@ -51,7 +49,7 @@
(do
(:send parent [name]))))
(-> (thread/new) (:send worker-tree) (:send "adam") (:send 0))
(-> (thread/new worker-tree) (:send "adam") (:send 0))
(def lines (thread/receive))
(map print lines)