Skip to content

Commit cc415a8

Browse files
committed
Enforce a four arguments function
1 parent ab0ed82 commit cc415a8

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/manifold/executor.clj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
3838
It represents the default implementation on `thread-factory` when the
3939
`new-thread-fn` argument is no passed."
40-
([group target name]
41-
(Thread. group target name))
42-
([group target name stack-size]
43-
(Thread. group target name stack-size)))
40+
[group target name stack-size]
41+
(Thread. group target name stack-size))
4442

4543
(defn ^ThreadFactory thread-factory
4644
"Returns a `java.util.concurrent.ThreadFactory`.
@@ -50,7 +48,7 @@
5048
| `executor-promise` | a promise eventually containing a `java.util.concurrent.Executor` that will be stored on `manifold.executor/executor-thread-local`. |
5149
| `stack-size` | the desired stack size for the new thread, or nil/zero to indicate that this parameter is to be ignored. |
5250
| `daemon?` | marks the created threads as either daemon or user threads. The Java Virtual Machine exits when the only threads running are all daemon threads. |
53-
| `new-thread-fn` | a three/four arguments function which returns an implementation of `java.lang.Thread` when called. |"
51+
| `new-thread-fn` | a four arguments function which returns an implementation of `java.lang.Thread` when called. |"
5452
([name-generator executor-promise]
5553
(thread-factory name-generator executor-promise nil true nil))
5654
([name-generator executor-promise stack-size]
@@ -66,9 +64,7 @@
6664
f #(do
6765
(.set executor-thread-local @executor-promise)
6866
(.run ^Runnable runnable))
69-
thread (if stack-size
70-
^Thread (new-thread nil f name stack-size)
71-
^Thread (new-thread nil f name))]
67+
thread ^Thread (new-thread nil f name (or stack-size 0))]
7268
(doto thread
7369
(.setDaemon daemon?)
7470
(.setContextClassLoader curr-loader))))))))

test/manifold/executor_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
(let [tf (thread-factory)]
5959
(.newThread tf (constantly nil)))
6060
(let [tf (thread-factory
61-
(fn [group target _]
62-
(proxy [Thread] [group target "custom-name"])))
61+
(fn [group target _ stack-size]
62+
(proxy [Thread] [group target "custom-name" stack-size])))
6363
thread (.newThread tf (constantly nil))]
6464
(is (= "custom-name" (.getName thread))))
6565
(let [tf (thread-factory

0 commit comments

Comments
 (0)