File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 5
5
[java.lang VirtualThread]
6
6
[java.time Duration])
7
7
(:require [manifold.stream :as s]
8
- [manifold.deferred :as d]))
8
+ [manifold.deferred :as d])
9
+ (:refer-clojure :exclude [send]))
9
10
10
11
(def ^{:dynamic true
11
12
:no-doc true } *local-semaphore*
330
331
true (s/buffer n)
331
332
true (s/realize-each )
332
333
seq? (s/stream->seq )))))
334
+
335
+ (defn send
336
+ " A version of `send` that uses a loom fiber for the execution of the function `f`.
337
+
338
+ See `clojure.core/send` for details"
339
+ [a f & args]
340
+ (apply send-via -static-executor a f args))
Original file line number Diff line number Diff line change 188
188
(let [success? (atom false )]
189
189
@(d/chain' (sut/fiber true ) (partial reset! success?))
190
190
(is @success?))))
191
+
192
+ (deftest send-test
193
+ (let [a (agent 0 )]
194
+ (testing " without arguments"
195
+ (sut/send a inc)
196
+ (await a)
197
+ (is (= 1 @a)))
198
+ (testing " with argument"
199
+ (sut/send a (constantly 0 ))
200
+ (sut/send a + 2 3 )
201
+ (await a)
202
+ (is (= 5 @a)))
203
+ (testing " with multiple arguments"
204
+ (sut/send a (constantly 0 ))
205
+ (sut/send a + 1 2 3 4 )
206
+ (await a)
207
+ (is (= 10 @a)))))
You can’t perform that action at this time.
0 commit comments