From e477c08c637f2475c113d7ddf313a69f70c8855f Mon Sep 17 00:00:00 2001 From: Fogus Date: Thu, 23 Jan 2025 09:41:25 -0500 Subject: [PATCH] Tweaking docstring and using custom ExecutorService for io-threads --- src/main/clojure/clojure/core/async.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/clojure/clojure/core/async.clj b/src/main/clojure/clojure/core/async.clj index e6f0a2c..6de3071 100644 --- a/src/main/clojure/clojure/core/async.clj +++ b/src/main/clojure/clojure/core/async.clj @@ -465,15 +465,16 @@ to catch and handle." (defonce ^:private ^Executor thread-macro-executor (Executors/newCachedThreadPool (conc/counted-thread-factory "async-thread-macro-%d" true))) -(defonce ^:private ^ExecutorService io-thread-exec thread-macro-executor) +(defonce ^:private ^ExecutorService io-thread-exec + (Executors/newCachedThreadPool (conc/counted-thread-factory "io-thread-macro-%d" true))) (defmacro io-thread "Asynchronously executes the body in a thread compatible with I/O workload, returning immediately to the calling thread. Only blocking operations should be used in io-thread bodies. - io-thread blocks should not (either directly or indirectly) perform operations - that never block and run pure compute operations. Parking ops + io-thread bodies should not (either directly or indirectly) perform operations + that never block nor run pure compute operations. Parking ops (i.e. ! and alt!/alts!) used in io-thread bodies will throw at runtime.