Skip to content

Commit

Permalink
Set default thread factory to virtual on structured-task-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Dec 3, 2023
1 parent 36dcaf5 commit e30b7c8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/promesa/exec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,16 @@
#?(:clj
(defn- options->thread-factory
{:no-doc true}
^ThreadFactory
[options]
(resolve-thread-factory
(or (:thread-factory options)
(:factory options)))))
(^ThreadFactory [options]
(resolve-thread-factory
(or (:thread-factory options)
(:factory options))))

(^ThreadFactory [options default]
(resolve-thread-factory
(or (:thread-factory options)
(:factory options)
default)))))

#?(:clj
(defn cached-executor
Expand Down Expand Up @@ -779,6 +784,7 @@
^Thread thr
^Throwable cause))))

;; FIXME: set correct default virtual thread factory
#?(:clj
(defn structured-task-scope
([]
Expand All @@ -787,8 +793,7 @@
(throw (IllegalArgumentException. "implementation not available"))))
([& {:keys [name preset] :as options}]
(pu/with-compile-cond structured-task-scope-available?
(let [tf (or (options->thread-factory options)
(deref default-thread-factory))]
(let [tf (options->thread-factory options :virtual)]
(case preset
:shutdown-on-success
(java.util.concurrent.StructuredTaskScope$ShutdownOnSuccess.
Expand All @@ -800,8 +805,8 @@

(java.util.concurrent.StructuredTaskScope.
^String name ^ThreadFactory tf)))
(throw (IllegalArgumentException. "implementation not available"))))))

(throw (IllegalArgumentException. "implementation not available"))))))

#?(:clj
(pu/with-compile-cond structured-task-scope-available?
Expand Down

0 comments on commit e30b7c8

Please sign in to comment.