[Git][clojure-team/core-async-clojure][upstream] New upstream version 1.5.648

Jérôme Charaoui (@lavamind) gitlab at salsa.debian.org
Mon Nov 28 23:50:57 GMT 2022



Jérôme Charaoui pushed to branch upstream at Debian Clojure Maintainers / core-async-clojure


Commits:
66d40aab by Jérôme Charaoui at 2022-10-21T00:10:38-04:00
New upstream version 1.5.648
- - - - -


17 changed files:

- .gitignore
- README.md
- VERSION_TEMPLATE
- deps.edn
- pom.xml
- project.clj
- src/main/clojure/cljs/core/async.cljs
- src/main/clojure/cljs/core/async/impl/channels.cljs
- src/main/clojure/cljs/core/async/impl/ioc_helpers.cljs
- src/main/clojure/cljs/core/async/impl/ioc_macros.clj
- src/main/clojure/cljs/core/async/impl/timers.cljs
- src/main/clojure/clojure/core/async.clj
- src/main/clojure/clojure/core/async/impl/channels.clj
- src/main/clojure/clojure/core/async/impl/ioc_macros.clj
- src/test/cljs/cljs/core/async/runner_tests.cljs
- src/test/cljs/cljs/core/async/tests.cljs
- src/test/clojure/clojure/core/async_test.clj


Changes:

=====================================
.gitignore
=====================================
@@ -1,6 +1,7 @@
 *.iml
 *init.clj
 .idea
+.nrepl-port
 out-simp
 out-simp-node
 out-adv


=====================================
README.md
=====================================
@@ -7,20 +7,20 @@ A Clojure library providing facilities for async programming and communication.
 
 This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository.
 
-Latest release: 1.2.603
+Latest release: 1.5.644
 
 * [All Released Versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22core.async%22)
 
 [deps.edn](https://clojure.org/reference/deps_and_cli) dependency information:
 
 ```clj
-  org.clojure/core.async {:mvn/version "1.2.603"}
+  org.clojure/core.async {:mvn/version "1.5.644"}
  ```
 
 [Leiningen](https://github.com/technomancy/leiningen) dependency information:
 
 ```clj
- [org.clojure/core.async "1.2.603"]
+ [org.clojure/core.async "1.5.644"]
 ```
 
 [Maven](http://maven.apache.org/) dependency information:
@@ -29,7 +29,7 @@ Latest release: 1.2.603
 <dependency>
   <groupId>org.clojure</groupId>
   <artifactId>core.async</artifactId>
-  <version>1.2.603</version>
+  <version>1.5.644</version>
 </dependency>
 ```
 
@@ -41,8 +41,8 @@ Latest release: 1.2.603
 
 ## Presentations
 
-* [Rich Hickey on core.async](http://www.infoq.com/presentations/clojure-core-async)
-* [Tim Baldridge on core.async](http://www.youtube.com/watch?v=enwIIGzhahw) from Clojure/conj 2013 ([code](https://github.com/halgari/clojure-conj-2013-core.async-examples)).
+* [Rich Hickey on core.async](https://www.youtube.com/watch?v=yJxFPoxqzWE)
+* [Tim Baldridge on core.async](https://www.youtube.com/watch?v=enwIIGzhahw) from Clojure/conj 2013 ([code](https://github.com/halgari/clojure-conj-2013-core.async-examples)).
 * Tim Baldridge on go macro internals - [part 1](https://www.youtube.com/watch?v=R3PZMIwXN_g) [part 2](https://www.youtube.com/watch?v=SI7qtuuahhU)
 
 ## Contributing 
@@ -63,6 +63,23 @@ Distributed under the Eclipse Public License, the same as Clojure.
 
 ## Changelog
 
+* next
+  * Update dep for tools.analyzer.jvm to 1.2.2
+* Release 1.5.644 on 2021.12.06
+  * Update dep for tools.analyzer.jvm to 1.2.1
+* Release 1.5.640 on 2021.11.23
+  * [ASYNC-204](https://clojure.atlassian.net/browse/ASYNC-204) (both) On put to closed channel, commit handler to allow pending alt ops to be cleaned up
+  * [ASYNC-235](https://clojure.atlassian.net/browse/ASYNC-235) (both) Fix ioc-macros/return-chan registers a callback with incorrect arity
+  * [ASYNC-144](https://clojure.atlassian.net/browse/ASYNC-144) (both) Tweak docstring in pipeline-async
+  * [ASYNC-238](https://clojure.atlassian.net/browse/ASYNC-238) (both) Fix a/map with empty chan vector hangs
+* Release 1.4.627 on 2021.11.03
+  * [ASYNC-132](https://clojure.atlassian.net/browse/ASYNC-132) (CLJS) Can't close over locals in #js in go)
+  * [ASYNC-117](https://clojure.atlassian.net/browse/ASYNC-117) (CLJS) let-bindings unavailable in #js literals in go-blocks
+  * Update dep for tools.analyzer.jvm to 1.2.0
+* Release 1.3.618 on 2021.04.26
+  * [ASYNC-237](https://clojure.atlassian.net/browse/ASYNC-237) (CLJS) timeout timers access array elements with out-of-bounds index
+* Release 1.3.610 on 2020.07.24
+  * Update dep for tools.analyzer.jvm to 1.1.0
 * Release 1.2.603 on 2020.05.11
   * Fix bug in cljs impl of onto-chan! in 1.2.598
 * Release 1.2.598 on 2020.05.11


=====================================
VERSION_TEMPLATE
=====================================
@@ -1 +1 @@
-1.3.GENERATED_VERSION
+1.5.GENERATED_VERSION


=====================================
deps.edn
=====================================
@@ -1,3 +1,6 @@
 {:paths ["src/main/clojure"]
  :deps
- {org.clojure/tools.analyzer.jvm {:mvn/version "1.1.0"}}}
+ {org.clojure/tools.analyzer.jvm {:mvn/version "1.2.2"}}
+ :aliases
+ {:cljs-test {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.597"}}
+              :extra-paths ["src/test/cljs"]}}}


=====================================
pom.xml
=====================================
@@ -3,7 +3,7 @@
   <groupId>org.clojure</groupId>
   <artifactId>core.async</artifactId>
   <!-- Don't set this manually! Call script/build/update_version -->
-  <version>1.3.610</version>
+  <version>1.5.648</version>
   <packaging>jar</packaging>
   <name>core.async</name>
   <description>Facilities for async programming and communication in Clojure</description>
@@ -20,14 +20,14 @@
   <parent>
     <groupId>org.clojure</groupId>
     <artifactId>pom.contrib</artifactId>
-    <version>1.0.0</version>
+    <version>1.1.0</version>
   </parent>
 
   <scm>
     <connection>scm:git:git://github.com/clojure/core.async.git</connection>
     <developerConnection>scm:git:git at github.com:clojure/core.async.git</developerConnection>
     <url>https://github.com/clojure/core.async</url>
-    <tag>core.async-1.3.610</tag>
+    <tag>v1.5.648</tag>
   </scm>
 
   <properties>
@@ -44,7 +44,7 @@
     <dependency>
       <groupId>org.clojure</groupId>
       <artifactId>tools.analyzer.jvm</artifactId>
-      <version>1.1.0</version>
+      <version>1.2.2</version>
     </dependency>
   </dependencies>
 


=====================================
project.clj
=====================================
@@ -5,7 +5,7 @@
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :parent [org.clojure/pom.contrib "1.0.0"]
   :dependencies [[org.clojure/clojure "1.9.0"]
-                 [org.clojure/tools.analyzer.jvm "1.0.0"]
+                 [org.clojure/tools.analyzer.jvm "1.2.2"]
                  [org.clojure/clojurescript "1.10.597" :scope "provided"]]
   :global-vars {*warn-on-reflection* true}
   :source-paths ["src/main/clojure"]


=====================================
src/main/clojure/cljs/core/async.cljs
=====================================
@@ -311,14 +311,14 @@
   "Takes elements from the from channel and supplies them to the to
   channel, subject to the async function af, with parallelism n. af
   must be a function of two arguments, the first an input value and
-  the second a channel on which to place the result(s). af must close!
-  the channel before returning.  The presumption is that af will
-  return immediately, having launched some asynchronous operation
-  whose completion/callback will manipulate the result channel. Outputs
-  will be returned in order relative to  the inputs. By default, the to
-  channel will be closed when the from channel closes, but can be
-  determined by the close?  parameter. Will stop consuming the from
-  channel if the to channel closes."
+  the second a channel on which to place the result(s). The
+  presumption is that af will return immediately, having launched some
+  asynchronous operation whose completion/callback will put results on
+  the channel, then close! it. Outputs will be returned in order
+  relative to the inputs. By default, the to channel will be closed
+  when the from channel closes, but can be determined by the close?
+  parameter. Will stop consuming the from channel if the to channel
+  closes. See also pipeline, pipeline-blocking."
   ([n to af from] (pipeline-async n to af from true))
   ([n to af from close?] (pipeline* n to af from close? nil :async)))
 
@@ -713,18 +713,20 @@
                            (when (zero? (swap! dctr dec))
                              (put! dchan (.slice rets 0)))))
                        (range cnt))]
-       (go-loop []
-         (reset! dctr cnt)
-         (dotimes [i cnt]
-           (try
-             (take! (chs i) (done i))
-             (catch js/Object e
-               (swap! dctr dec))))
-         (let [rets (<! dchan)]
-           (if (some nil? rets)
-             (close! out)
-             (do (>! out (apply f rets))
-                 (recur)))))
+       (if (zero? cnt)
+         (close! out)
+         (go-loop []
+           (reset! dctr cnt)
+           (dotimes [i cnt]
+             (try
+               (take! (chs i) (done i))
+               (catch js/Object e
+                 (swap! dctr dec))))
+           (let [rets (<! dchan)]
+             (if (some nil? rets)
+               (close! out)
+               (do (>! out (apply f rets))
+                   (recur))))))
        out)))
 
 (defn merge


=====================================
src/main/clojure/cljs/core/async/impl/channels.cljs
=====================================
@@ -46,49 +46,53 @@
     (assert (not (nil? val)) "Can't put nil on a channel")
     ;; bug in CLJS compiler boolean inference - David
     (let [^boolean closed closed]
-      (if (or closed (not ^boolean (impl/active? handler)))
+      (if (not ^boolean (impl/active? handler))
         (box (not closed))
-        (if (and buf (not (impl/full? buf)))
+        (if closed
           (do
             (impl/commit handler)
-            (let [done? (reduced? (add! buf val))
-                  take-cbs (loop [takers []]
-                             (if (and (pos? (.-length takes)) (pos? (count buf)))
-                               (let [^not-native taker (.pop takes)]
-                                 (if ^boolean (impl/active? taker)
-                                   (let [ret (impl/commit taker)
-                                         val (impl/remove! buf)]
-                                     (recur (conj takers (fn [] (ret val)))))
-                                   (recur takers)))
-                               takers))]
-              (when done? (abort this))
-              (when (seq take-cbs)
-                (doseq [f take-cbs]
-                  (dispatch/run f)))
-              (box true)))
-          (let [taker (loop []
-                        (let [^not-native taker (.pop takes)]
-                          (when taker
-                            (if (impl/active? taker)
-                              taker
-                              (recur)))))]
-            (if taker
-              (let [take-cb (impl/commit taker)]
-                (impl/commit handler)
-                (dispatch/run (fn [] (take-cb val)))
-                (box true))
-              (do
-                (if (> dirty-puts MAX_DIRTY)
-                  (do (set! dirty-puts 0)
-                      (.cleanup puts put-active?))
-                  (set! dirty-puts (inc dirty-puts)))
-                (when (impl/blockable? handler)
-                  (assert (< (.-length puts) impl/MAX-QUEUE-SIZE)
-                    (str "No more than " impl/MAX-QUEUE-SIZE
-                         " pending puts are allowed on a single channel."
-                         " Consider using a windowed buffer."))
-                  (.unbounded-unshift puts (PutBox. handler val)))
-                nil)))))))
+            (box false))
+          (if (and buf (not (impl/full? buf)))
+            (do
+              (impl/commit handler)
+              (let [done? (reduced? (add! buf val))
+                    take-cbs (loop [takers []]
+                               (if (and (pos? (.-length takes)) (pos? (count buf)))
+                                 (let [^not-native taker (.pop takes)]
+                                   (if ^boolean (impl/active? taker)
+                                     (let [ret (impl/commit taker)
+                                           val (impl/remove! buf)]
+                                       (recur (conj takers (fn [] (ret val)))))
+                                     (recur takers)))
+                                 takers))]
+                (when done? (abort this))
+                (when (seq take-cbs)
+                  (doseq [f take-cbs]
+                    (dispatch/run f)))
+                (box true)))
+            (let [taker (loop []
+                          (let [^not-native taker (.pop takes)]
+                            (when taker
+                              (if (impl/active? taker)
+                                taker
+                                (recur)))))]
+              (if taker
+                (let [take-cb (impl/commit taker)]
+                  (impl/commit handler)
+                  (dispatch/run (fn [] (take-cb val)))
+                  (box true))
+                (do
+                  (if (> dirty-puts MAX_DIRTY)
+                    (do (set! dirty-puts 0)
+                        (.cleanup puts put-active?))
+                    (set! dirty-puts (inc dirty-puts)))
+                  (when (impl/blockable? handler)
+                    (assert (< (.-length puts) impl/MAX-QUEUE-SIZE)
+                      (str "No more than " impl/MAX-QUEUE-SIZE
+                        " pending puts are allowed on a single channel."
+                        " Consider using a windowed buffer."))
+                    (.unbounded-unshift puts (PutBox. handler val)))
+                  nil))))))))
   impl/ReadPort
   (take! [this ^not-native handler]
     (if (not ^boolean (impl/active? handler))


=====================================
src/main/clojure/cljs/core/async/impl/ioc_helpers.cljs
=====================================
@@ -69,7 +69,7 @@
 (defn return-chan [state value]
   (let [^not-native c (aget state USER-START-IDX)]
            (when-not (nil? value)
-             (impl/put! c value (fn-handler (fn [] nil))))
+             (impl/put! c value (fn-handler (fn [_] nil))))
            (impl/close! c)
            c))
 


=====================================
src/main/clojure/cljs/core/async/impl/ioc_macros.clj
=====================================
@@ -16,7 +16,8 @@
             [clojure.core.async.impl.protocols :as impl]
             [clojure.core.async.impl.dispatch :as dispatch]
             [cljs.analyzer :as cljs])
-  (:import [java.util.concurrent.locks Lock]))
+  (:import [cljs.tagged_literals JSValue]
+           [java.util.concurrent.locks Lock]))
 
 (defn debug [x]
   (binding [*out* *err*]
@@ -403,6 +404,7 @@
                           (map? x) :map
                           (set? x) :set
                           (vector? x) :vector
+                          (instance? JSValue x) :js-value
                           :else :default)))
 
 (defn item-to-ssa [x]
@@ -793,6 +795,13 @@
   [x]
   (-item-to-ssa `(vector ~@x)))
 
+(defmethod -item-to-ssa :js-value
+  [^JSValue x]
+  (let [items (.-val x)]
+    (if (map? items)
+      (-item-to-ssa `(cljs.core/js-obj ~@(mapcat (fn [[k v]] [(name k) v]) items)))
+      (-item-to-ssa `(cljs.core/array ~@items)))))
+
 (defmethod -item-to-ssa :set
   [x]
   (-item-to-ssa `(hash-set ~@x)))


=====================================
src/main/clojure/cljs/core/async/impl/timers.cljs
=====================================
@@ -76,8 +76,13 @@
             (loop [i 0]
               (when (<= i level)
                 (let [links (.-forward (aget update i))]
-                  (aset (.-forward x) i (aget links i))
-                  (aset links i x))
+                  (if (< i (alength (.-forward x)))
+                    (aset (.-forward x) i (aget links i))
+                    (.push (.-forward x) (when (< i (alength links))
+                                           (aget links i))))
+                  (if (< i (alength links))
+                    (aset links i x)
+                    (.push links x)))
                 (recur (inc i)))))))))
 
   (remove [coll k]


=====================================
src/main/clojure/clojure/core/async.clj
=====================================
@@ -599,15 +599,14 @@ to catch and handle."
   "Takes elements from the from channel and supplies them to the to
   channel, subject to the async function af, with parallelism n. af
   must be a function of two arguments, the first an input value and
-  the second a channel on which to place the result(s). af must close!
-  the channel before returning.  The presumption is that af will
-  return immediately, having launched some asynchronous operation
-  (i.e. in another thread) whose completion/callback will manipulate
-  the result channel. Outputs will be returned in order relative to
-  the inputs. By default, the to channel will be closed when the from
-  channel closes, but can be determined by the close?  parameter. Will
-  stop consuming the from channel if the to channel closes. See also
-  pipeline, pipeline-blocking."
+  the second a channel on which to place the result(s). The
+  presumption is that af will return immediately, having launched some
+  asynchronous operation whose completion/callback will put results on
+  the channel, then close! it. Outputs will be returned in order
+  relative to the inputs. By default, the to channel will be closed
+  when the from channel closes, but can be determined by the close?
+  parameter. Will stop consuming the from channel if the to channel
+  closes. See also pipeline, pipeline-blocking."
   ([n to af from] (pipeline-async n to af from true))
   ([n to af from close?] (pipeline* n to af from close? nil :async)))
 
@@ -1016,18 +1015,20 @@ to catch and handle."
                            (when (zero? (swap! dctr dec))
                              (put! dchan (java.util.Arrays/copyOf rets cnt)))))
                        (range cnt))]
-       (go-loop []
-         (reset! dctr cnt)
-         (dotimes [i cnt]
-           (try
-             (take! (chs i) (done i))
-             (catch Exception e
-               (swap! dctr dec))))
-         (let [rets (<! dchan)]
-           (if (some nil? rets)
-             (close! out)
-             (do (>! out (apply f rets))
-                 (recur)))))
+       (if (zero? cnt)
+         (close! out)
+         (go-loop []
+           (reset! dctr cnt)
+           (dotimes [i cnt]
+             (try
+               (take! (chs i) (done i))
+               (catch Exception e
+                 (swap! dctr dec))))
+           (let [rets (<! dchan)]
+             (if (some nil? rets)
+               (close! out)
+               (do (>! out (apply f rets))
+                   (recur))))))
        out)))
 
 (defn merge


=====================================
src/main/clojure/clojure/core/async/impl/channels.clj
=====================================
@@ -71,8 +71,12 @@
    (.lock mutex)
    (cleanup this)
    (if @closed
-     (do (.unlock mutex)
-         (box false))
+     (let [^Lock handler handler]
+       (.lock handler)
+       (when (impl/active? handler) (impl/commit handler))
+       (.unlock handler)
+       (.unlock mutex)
+       (box false))
      (let [^Lock handler handler]
        (if (and buf (not (impl/full? buf)) (not (.isEmpty takes)))
          (do


=====================================
src/main/clojure/clojure/core/async/impl/ioc_macros.clj
=====================================
@@ -1004,11 +1004,10 @@
 (defn return-chan [state value]
   (let [c (aget-object state USER-START-IDX)]
            (when-not (nil? value)
-             (impl/put! c value (fn-handler (fn [] nil))))
+             (impl/put! c value (fn-handler (fn [_] nil))))
            (impl/close! c)
            c))
 
-
 (def async-custom-terminators
   {'clojure.core.async/<! `take!
    'clojure.core.async/>! `put!


=====================================
src/test/cljs/cljs/core/async/runner_tests.cljs
=====================================
@@ -193,7 +193,7 @@
                (finally (reset! a true))))]
       (is (and @a v)))
 
-    (testing "https://dev.clojure.org/jira/browse/ASYNC-73"
+    (testing "https://clojure.atlassian.net/browse/ASYNC-73"
       (let [a (atom false)]
         (runner
          (try
@@ -211,7 +211,7 @@
              (catch :default e
                true)))))
 
-    (testing "https://dev.clojure.org/jira/browse/ASYNC-172"
+    (testing "https://clojure.atlassian.net/browse/ASYNC-172"
       (is (= 123 (runner
                   (try (throw 123)
                        (catch :default e 123))))))


=====================================
src/test/cljs/cljs/core/async/tests.cljs
=====================================
@@ -18,7 +18,8 @@
    [cljs.core.async.impl.timers :as timers :refer [timeout]]
    [cljs.core.async.impl.protocols :refer [full? add! remove!]]
    [cljs.core.async.test-helpers :refer [latch inc!]]
-   [cljs.test :as test :refer-macros [deftest is run-tests async testing]]))
+   [cljs.test :as test :refer-macros [deftest is run-tests async testing]]
+   [goog.object :as gobj]))
 
 (enable-console-print!)
 
@@ -489,3 +490,49 @@
         (is (= old 42))
         (is (= foo 42)))
       (done))))
+
+(deftest test-js-literals
+  (async done
+    (go
+      (let [arr #js [1 2 3]]
+        (is (= 2 (aget arr 1))))
+      (let [obj #js {:foo 1}]
+        (is (= 1 (gobj/get obj "foo"))))
+      (testing "ASYNC-132 / 117- can't close over local in #js in go"
+        (let [bar 42]
+          (is (= 42 (aget #js [1 bar 3] 1)))
+          (is (= 42 (gobj/get #js {:foo bar} "foo")))))
+      (done))))
+
+(deftest test-js-literals-chans
+  (let [c0 (chan)
+        c1 (chan)]
+   (async done
+     (go
+       (let [arr #js [1 (<! c0) 3]]
+         (is (= 2 (aget arr 1))))
+       (let [obj #js {:foo (<! c1)}]
+         (is (= 1 (gobj/get obj "foo"))))
+       (done))
+     (go
+       (>! c0 2)
+       (>! c1 1)))))
+
+(deftest test-write-on-closed
+  (let [closed (doto (chan) close!)
+        open (chan)]
+    (async done
+      (go
+        (is (= :ok
+              (try
+                (dotimes [_ 1e4] (alts! [open [closed true]] :priority true))
+                :ok
+                (catch :default e
+                  :ko))))
+        (done)))))
+
+(comment
+
+  (test/run-tests)
+
+  )


=====================================
src/test/clojure/clojure/core/async_test.clj
=====================================
@@ -264,7 +264,8 @@
            (<!! (a/into [] (a/map + [(a/to-chan! (range 4))
                                      (a/to-chan! (range 4))
                                      (a/to-chan! (range 4))
-                                     (a/to-chan! (range 4))]))))))
+                                     (a/to-chan! (range 4))])))))
+    (is (nil? (<!! (a/map + [])))))
   (testing "merge"
     ;; merge uses alt, so results can be in any order, we're using
     ;; frequencies as a way to make sure we get the right result.
@@ -453,3 +454,13 @@
 (deftest test-transduce
   (is (= [1 2 3 4 5]
          (<!! (a/transduce (mapping inc) conj [] (a/to-chan! (range 5)))))))
+
+(deftest test-write-on-closed
+  (let [closed (doto (a/chan) a/close!)
+        open (a/chan)]
+    (is (= :ok
+           (try
+             (dotimes [_ 1e4] (a/alts!! [open [closed true]] :priority true))
+             :ok
+             (catch AssertionError e
+               :ko))))))



View it on GitLab: https://salsa.debian.org/clojure-team/core-async-clojure/-/commit/66d40aab5848a6844a2d69745115f684e95d229b

-- 
View it on GitLab: https://salsa.debian.org/clojure-team/core-async-clojure/-/commit/66d40aab5848a6844a2d69745115f684e95d229b
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221128/f4667699/attachment.htm>


More information about the pkg-java-commits mailing list