Skip to content

Commit

Permalink
Cleaned up pool thread names and added test for failing parking ops
Browse files Browse the repository at this point in the history
  • Loading branch information
fogus committed Jan 24, 2025
1 parent 3158bb7 commit a6151f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/clojure/clojure/core/async.clj
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ to catch and handle."
(#'clojure.core.async.impl.go/go-impl &env body))

(defonce ^:private ^Executor thread-macro-executor
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-thread-macro-%d" true)))
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-thread-%d" true)))

(defonce ^:private ^ExecutorService io-thread-exec
(Executors/newCachedThreadPool (conc/counted-thread-factory "io-thread-macro-%d" true)))
(Executors/newCachedThreadPool (conc/counted-thread-factory "async-io-thread-%d" true)))

(defn thread-call
"Executes f in another thread, returning immediately to the calling
Expand Down
12 changes: 10 additions & 2 deletions src/test/clojure/clojure/core/async_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,22 @@
(is (<!! (thread test-dyn))))))

(deftest io-thread-tests
(testing "io-thread"
(testing "io-thread blocking ops"
(let [c1 (chan)
c2 (chan)
c3 (chan)]
(io-thread (>!! c2 (clojure.string/upper-case (<!! c1))))
(io-thread (>!! c3 (clojure.string/reverse (<!! c2))))
(>!! c1 "loop")
(is (= "POOL" (<!! c3))))))
(is (= "POOL" (<!! c3)))))
(testing "io-thread parking op should fail"
(let [c1 (chan)]
(io-thread
(try
(>! c1 :no)
(catch AssertionError _
(>!! c1 :yes))))
(is (= :yes (<!! c1))))))

(deftest ops-tests
(testing "map<"
Expand Down

0 comments on commit a6151f2

Please sign in to comment.