<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in core.async</title>
<link>https://ask.clojure.org/index.php/questions/contrib-libs/core-async</link>
<description></description>
<item>
<title>`flow/ping-proc` can be slow or fail to respond, even when process isn't busy</title>
<link>https://ask.clojure.org/index.php/14911/flow-ping-proc-slow-fail-respond-even-when-process-isnt-busy</link>
<description>&lt;p&gt;I've run into a few cases where &lt;code&gt;flow/ping&lt;/code&gt; and &lt;code&gt;flow/ping-proc&lt;/code&gt; are slow and timeout.&lt;/p&gt;
&lt;p&gt;I was able to track the issue down to this line &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/b871f3519de6843a9f5ce66cf8d5c6cbe44d3222/src/main/clojure/clojure/core/async/flow/impl.clj#L273&quot;&gt;https://github.com/clojure/core.async/blob/b871f3519de6843a9f5ce66cf8d5c6cbe44d3222/src/main/clojure/clojure/core/async/flow/impl.clj#L273&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(async/&amp;gt;!! c
            (walk/postwalk datafy
                           #::flow{:pid pid, :status status
                                   :state state,
                                   :count count
                                   :ins pins :outs pouts}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This causes the state of the flow process to be traversed and datafied.&lt;/p&gt;
&lt;p&gt;In one case, I had some process state that threw an exception when datafied due to an incomplete datafy extension. This caused &lt;code&gt;flow/ping-proc&lt;/code&gt; to silently fail. No errors were reported.&lt;/p&gt;
&lt;p&gt;In some other cases, the flow processes were working with large values. Walking the process state was slow and caused pings to respond slowly.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14911/flow-ping-proc-slow-fail-respond-even-when-process-isnt-busy</guid>
<pubDate>Wed, 28 Jan 2026 18:01:40 +0000</pubDate>
</item>
<item>
<title>flow monitoring tool serves resources from unqualified path</title>
<link>https://ask.clojure.org/index.php/14748/flow-monitoring-tool-serves-resources-from-unqualified-path</link>
<description>&lt;p&gt;For flow monitoring, HTML, CSS, and javascript assets are served from the resource path &quot;public/&quot;. If there is another library on the classpath that also has a resource at &quot;public/index.html&quot;, then flow monitoring's assets will get clobbered and serve the wrong web page instead. Alternatively, flow monitoring may clobber someone else's resources.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async.flow-monitor/blob/6248a5d8e4228ab5974289559e3cb11ff3152263/src/clojure/core/async/flow_monitor.clj#L104&quot;&gt;https://github.com/clojure/core.async.flow-monitor/blob/6248a5d8e4228ab5974289559e3cb11ff3152263/src/clojure/core/async/flow_monitor.clj#L104&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This can be addressed by moving resources to a qualified path like &quot;clojure/core/async/flow_monitor/public/index.html&quot;.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14748/flow-monitoring-tool-serves-resources-from-unqualified-path</guid>
<pubDate>Tue, 04 Nov 2025 20:57:47 +0000</pubDate>
</item>
<item>
<title>`pipeline-blocking` uses `thread` internally instead of `io-thread`</title>
<link>https://ask.clojure.org/index.php/14738/pipeline-blocking-uses-thread-internally-instead-of-thread</link>
<description>&lt;p&gt;&lt;code&gt;pipeline-blocking&lt;/code&gt; is explicitly meant for blocking operations (implying I/O). However, internally it uses &lt;code&gt;thread&lt;/code&gt; rather than &lt;code&gt;io-thread&lt;/code&gt; for processing: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L637-L640&quot;&gt;https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L637-L640&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Since 1.9.829-alpha2 this has practical implications, as only &lt;code&gt;io-thread&lt;/code&gt; will utilize virtual threads, when available.&lt;/p&gt;
&lt;p&gt;Can this be fixed / changed?&lt;br&gt;
If not, can an explicit &lt;code&gt;pipeline-io&lt;/code&gt; (or similar)  function be added to support this use case?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14738/pipeline-blocking-uses-thread-internally-instead-of-thread</guid>
<pubDate>Wed, 29 Oct 2025 15:54:00 +0000</pubDate>
</item>
<item>
<title>Choosing between core.async pipelines</title>
<link>https://ask.clojure.org/index.php/14732/choosing-between-core-async-pipelines</link>
<description>&lt;p&gt;It's no longer clear what kind of pipeline is suitable for what kind of task in &lt;code&gt;core.async&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Previously, my understanding was that anything I/O-bound should go into &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/v1.9.829-alpha2/src/main/clojure/clojure/core/async.clj#L682-L686&quot;&gt;&lt;code&gt;pipeline-blocking&lt;/code&gt;&lt;/a&gt;, while CPU-bound tasks went into regular (i.e. &lt;code&gt;:compute&lt;/code&gt;) &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/v1.9.829-alpha2/src/main/clojure/clojure/core/async.clj#L665-L680&quot;&gt;&lt;code&gt;pipeline&lt;/code&gt;&lt;/a&gt;. But a while back &lt;code&gt;:compute&lt;/code&gt; pipelines were &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/commit/3429e3e1f1d49403bf9608b36dbd6715ffe4dd4f&quot;&gt;changed&lt;/a&gt; to use threads instead of go-blocks. And now, with the introduction of &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/news/2025/10/01/async_virtual_threads&quot;&gt;virtual threads&lt;/a&gt;, &lt;code&gt;pipeline-async&lt;/code&gt; seems like the right choice for I/O-bound tasks.&lt;/p&gt;
&lt;p&gt;It seems that workloads are being classified into one of &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/v1.9.829-alpha2/src/main/clojure/clojure/core/async/impl/dispatch.clj#L130-L132&quot;&gt;three types&lt;/a&gt;: &lt;code&gt;:compute&lt;/code&gt;, &lt;code&gt;:io&lt;/code&gt;, and &lt;code&gt;:mixed&lt;/code&gt;. Is &lt;code&gt;:async&lt;/code&gt; meant to be the equivalent of &lt;code&gt;:io&lt;/code&gt;, and &lt;code&gt;:blocking&lt;/code&gt; the equivalent of &lt;code&gt;:mixed&lt;/code&gt;? I don't think that's original semantics, but it seems to be the mapping now.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14732/choosing-between-core-async-pipelines</guid>
<pubDate>Sun, 26 Oct 2025 22:19:12 +0000</pubDate>
</item>
<item>
<title>Replace core.async’s internal LinkedList queue with ArrayDeque?</title>
<link>https://ask.clojure.org/index.php/14696/replace-core-asyncs-internal-linkedlist-queue-arraydeque</link>
<description>&lt;p&gt;Hi! While reading the channel implementation I noticed the internal queue is a &lt;code&gt;java.util.LinkedList&lt;/code&gt;:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/channels.clj&quot;&gt;https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/channels.clj&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The common JVM guidance these days is to prefer &lt;code&gt;java.util.ArrayDeque&lt;/code&gt; for FIFO/LIFO queues due to better locality and lower GC overhead. For example, the JDK docs state: “This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue.”&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html&quot;&gt;https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html&lt;/a&gt;&lt;br&gt;
Related SO discussion: &lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/questions/6163166/why-is-arraydeque-better-than-linkedlist&quot;&gt;https://stackoverflow.com/questions/6163166/why-is-arraydeque-better-than-linkedlist&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A few questions for the maintainers:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Was &lt;code&gt;LinkedList&lt;/code&gt; originally chosen for a specific reason (e.g., very old JDK compatibility)?&lt;/li&gt;
&lt;li&gt;Are there behaviors in channels that specifically rely on &lt;code&gt;LinkedList&lt;/code&gt; (e.g., allowing null, I believe channels disallow nil anyway, or particular iterator characteristics), or would &lt;code&gt;ArrayDeque&lt;/code&gt; be a drop-in replacement for the add/remove-from-ends operations used?&lt;/li&gt;
&lt;li&gt;If we provide a small PR and benchmark showing an improvement (lower allocations / better throughput under contention), would such a change be considered?&lt;/li&gt;
&lt;li&gt;Since &lt;code&gt;ArrayDeque&lt;/code&gt; is available on Java 8+, and current Clojure/core.async baselines target that or newer, is there any remaining compatibility concern?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Context: there was an older conversation in Clojurians (#clojure) that suggested ArrayDeque could reduce GC pressure under load and that the original choice may have been influenced by older JDKs:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1526551888000376&quot;&gt;https://clojurians.slack.com/archives/C03S1KBA2/p1526551888000376&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If this sounds reasonable, I’m happy to run the core.async test suite, add JMH-style benchmarks focused on channel put/take hot paths, and submit a PR.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14696/replace-core-asyncs-internal-linkedlist-queue-arraydeque</guid>
<pubDate>Tue, 02 Sep 2025 08:02:18 +0000</pubDate>
</item>
<item>
<title>Typos in Flow guide</title>
<link>https://ask.clojure.org/index.php/14686/typos-in-flow-guide</link>
<description>&lt;p&gt;As reported by a &lt;a rel=&quot;nofollow&quot; href=&quot;https://news.ycombinator.com/item?id=44936309&quot;&gt;Hacker News user&lt;/a&gt;, there are typos in the &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.github.io/core.async/flow-guide.html&quot;&gt;Flow Guide&lt;/a&gt;  :&lt;/p&gt;
&lt;p&gt;&quot;excepiton&quot; should be &quot;exception&quot;&lt;br&gt;
&quot;provded&quot; should be &quot;provided&quot;&lt;/p&gt;
&lt;p&gt;and also, it seems that in the transition section, &quot;The description arity takes the current state ...&quot; should be &quot;The transition arity takes the current state ...&quot;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14686/typos-in-flow-guide</guid>
<pubDate>Mon, 18 Aug 2025 08:19:35 +0000</pubDate>
</item>
<item>
<title>Is core.async.flow available in ClojureScript?</title>
<link>https://ask.clojure.org/index.php/14633/is-core-async-flow-available-in-clojurescript</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I know it's early days for core.async.flow but I thought I would give it a try in one of my ClojureScript projects.&lt;/p&gt;
&lt;p&gt;I've got &lt;code&gt;{:mvn/version &quot;1.9.808-alpha1&quot;}&lt;/code&gt; in my deps.edn but I'm getting the following error when I try to access the namespace:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;No such namespace: clojure.core.async.flow, could not locate clojure/core/async/flow.cljs&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks for your help.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14633/is-core-async-flow-available-in-clojurescript</guid>
<pubDate>Thu, 17 Jul 2025 08:31:10 +0000</pubDate>
</item>
<item>
<title>what kind of systems could be made with clojure.async.flow?</title>
<link>https://ask.clojure.org/index.php/14526/what-kind-of-systems-could-be-made-with-clojure-async-flow</link>
<description>&lt;p&gt;Trying to capture mechanical essence of &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.github.io/core.async/flow.html&quot;&gt;clojure.async.flow&lt;/a&gt; with basic terms instead of flow own terms i guess that clojure.async.flow allows to structure a system as a set of stateful functions running concurrently in the same jvm process and interacting with each other explicitly via channels.&lt;/p&gt;
&lt;p&gt;what kind of systems could be made with clojure.async.flow?&lt;/p&gt;
&lt;p&gt;it's definitely not naive service which handles API http requests, transforms it somehow and puts it into database.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14526/what-kind-of-systems-could-be-made-with-clojure-async-flow</guid>
<pubDate>Tue, 29 Apr 2025 15:48:35 +0000</pubDate>
</item>
<item>
<title>core.async go block error with clojure 1.12 method values</title>
<link>https://ask.clojure.org/index.php/14425/core-async-go-block-error-with-clojure-1-12-method-values</link>
<description>&lt;p&gt;I haven't seen this reported. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(Long/.toString 123) ;;works
(a/&amp;lt;!! (a/thread (Long/.toString 123))) ;;works
(a/go (Long/.toString 123)) ;;error
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Note: The following stack trace applies to the reader or compiler, your code was not executed.

CompilerException Syntax error macroexpanding a/go at (1:1). {:clojure.error/phase :macro-syntax-check, :clojure.error/line 1, :clojure.error/column 1, :clojure.error/source &quot;NO_SOURCE_PATH&quot;, :clojure.error/symbol a/go}
ExceptionInfo No matching method: .toString for class: class java.lang.Long and arity: 1 {:method .toString, :class java.lang.Long, :argc 1, :file &quot;NO_SOURCE_PATH&quot;, :column 7, :line 1}
	clojure.tools.analyzer.passes.jvm.validate/validate-call (validate.clj:127)
	clojure.tools.analyzer.passes.jvm.validate/validate-call (validate.clj:87)
	clojure.tools.analyzer.passes.jvm.validate/eval4802/fn--4803 (validate.clj:137)
	clojure.lang.MultiFn.invoke (MultiFn.java:229)
	clojure.tools.analyzer.passes.jvm.validate/validate (validate.clj:265)
	clojure.tools.analyzer.passes.jvm.validate/validate (validate.clj:240)
	clojure.lang.Var.invoke (Var.java:386)
	clojure.tools.analyzer.passes/compile-passes/fn--3424/fn--3429 (passes.clj:167)
	clojure.tools.analyzer.passes/compile-passes/fn--3424/fn--3431 (passes.clj:169)
	clojure.tools.analyzer.passes/compile-passes/fn--3424/fn--3431 (passes.clj:169)
	clojure.tools.analyzer.passes/compile-passes/fn--3424/fn--3431 (passes.clj:169)
	clojure.core/partial/fn--5929 (core.clj:2648)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14425/core-async-go-block-error-with-clojure-1-12-method-values</guid>
<pubDate>Tue, 25 Feb 2025 19:17:23 +0000</pubDate>
</item>
<item>
<title>The cljs docstring of `clojure.core.async/promise-chan` does not mention that it returns the value repeatedly</title>
<link>https://ask.clojure.org/index.php/14088/docstring-clojure-promise-mention-returns-value-repeatedly</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1L9DN/p1724775264055089&quot;&gt;Question in slack&lt;/a&gt; about why a promise chan &quot;returns the result of the promise every time you call&quot;.&lt;/p&gt;
&lt;p&gt;The docstring in clj includes the phrase&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Consumers will block until either a value is placed in the channel or the&lt;br&gt;
  channel is closed, then return the value (or nil) forever.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is missing from the clojurescript version of the docstring:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Creates a promise channel with an optional transducer, and an optional&lt;br&gt;
  exception-handler. A promise channel can take exactly one value that consumers&lt;br&gt;
  will receive. Once full, puts complete but val is dropped (no transfer).&lt;br&gt;
  Consumers will block until either a value is placed in the channel or the&lt;br&gt;
  channel is closed. See chan for the semantics of xform and ex-handler.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/aa6b951301fbdcf5a13cdaaecb4b1a908dc8a978/src/main/clojure/cljs/core/async.cljs#L76&quot;&gt;source&lt;/a&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14088/docstring-clojure-promise-mention-returns-value-repeatedly</guid>
<pubDate>Tue, 27 Aug 2024 16:28:38 +0000</pubDate>
</item>
<item>
<title>Why do core.async timeouts rely on non-monotonic system clock?</title>
<link>https://ask.clojure.org/index.php/13420/why-do-core-async-timeouts-rely-on-non-monotonic-system-clock</link>
<description>&lt;p&gt;&lt;code&gt;clojure.core.async/timeout&lt;/code&gt; uses &lt;code&gt;System/currentTimeMillis&lt;/code&gt; to calculate its deadline (see &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/322adc72852bb79c143ebe5d203d100534fda8f2/src/main/clojure/clojure/core/async/impl/timers.clj#L29&quot;&gt;here&lt;/a&gt; and &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/322adc72852bb79c143ebe5d203d100534fda8f2/src/main/clojure/clojure/core/async/impl/timers.clj#L62&quot;&gt;here&lt;/a&gt;). While &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/System.html#currentTimeMillis()&quot;&gt;the docstring for &lt;code&gt;System/currentTimeMillis&lt;/code&gt;&lt;/a&gt; doesn't mention it explicitly, it's quite clearly unsuitable for this purpose because it returns the current time as reported by the OS. Since that time can change arbitrarily (e.g. by correction via NTP), the deadline calculations may end up inconsistent. This behavior is very much intended, see e.g. &lt;a rel=&quot;nofollow&quot; href=&quot;https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8061480&quot;&gt;this ticket&lt;/a&gt; where it was suggested to switch &lt;code&gt;System/currentTimeMillis&lt;/code&gt; over to a monotonic clock where possible. It was refused with the following comment:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;System.currentTimeMillis() is required to return milliseconds since the epoch and should reflect external changes to the system/wall-clock time. CLOCK_MONOTONIC_COARSE does not provide that and so can not be used for this purpose.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Also, the &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/concurrent/ScheduledExecutorService.html&quot;&gt;docstring for &lt;code&gt;java.util.concurrent.ScheduledExecutorService&lt;/code&gt;&lt;/a&gt; states this quite plainly:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;All schedule methods accept relative delays and periods as arguments, not absolute times or dates. It is a simple matter to transform an absolute time represented as a Date to the required form. For example, to schedule at a certain future date, you can use: schedule(task, date.getTime() - System.currentTimeMillis(), TimeUnit.MILLISECONDS). Beware however that expiration of a relative delay need not coincide with the current Date at which the task is enabled due to network time synchronization protocols, clock drift, or other factors.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Since all we care about here is deltas, it seems advisable to switch to &lt;code&gt;System/nanoTime&lt;/code&gt; instead. Unfortunately, &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/System.html#nanoTime()&quot;&gt;its docstring&lt;/a&gt; &lt;em&gt;also&lt;/em&gt; doesn't make its properties very obvious. It doesn't mention that it's a monotonic clock but only hints at it by stating:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds. This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. [...] The values returned by this method become meaningful only when the difference between two such values, obtained within the same instance of a Java virtual machine, is computed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A case in point for using it is OpenJDK's implementation of &lt;code&gt;java.util.concurrent.ScheduledThreadPoolExecutor&lt;/code&gt; whose &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/openjdk/jdk/blob/c86592d38d651beac40f1da43c718a2d4b17bd19/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java#L524-L530&quot;&gt;deadline calculation method does so&lt;/a&gt;, as well as its &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/openjdk/jdk/blob/c86592d38d651beac40f1da43c718a2d4b17bd19/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java#L244-L246&quot;&gt;&lt;code&gt;getDelay&lt;/code&gt; implementation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Furthermore--if it's anything to go by--various StackOverflow posts also discuss this and arrive at the same conclusion, e.g. &lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/questions/510462/is-system-nanotime-completely-useless/54566928#54566928&quot;&gt;this one&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Nonetheless, nanoTime() should still be preferred for implementing timed blocking, interval waiting, timeouts, etc. to currentTimeMillis() because the latter is a subject to the &quot;time going backward&quot; phenomenon (e. g. due to server time correction), i. e. currentTimeMillis() is not suitable for measuring time intervals at all. See this answer for more information.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;See also &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/10306/core-cache-ttlcacheq-timer-is-not-monotonic?show=10306#q10306&quot;&gt;a similar question about &lt;code&gt;core.cache&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13420/why-do-core-async-timeouts-rely-on-non-monotonic-system-clock</guid>
<pubDate>Wed, 01 Nov 2023 16:26:33 +0000</pubDate>
</item>
<item>
<title>Virtual thread executor for core.async</title>
<link>https://ask.clojure.org/index.php/13366/virtual-thread-executor-for-core-async</link>
<description>&lt;p&gt;There have been a few people on Slack asking about virtual threads and core.async before. Here is an example of one such thread &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C05423W6H/p1677676131782299&quot;&gt;https://clojurians.slack.com/archives/C05423W6H/p1677676131782299&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Of course, consideration is also needed for ClojureScript and non-Loom code. I would assume a virtual thread aware implementation of core.async would probably exist in a dedicated namespace to prevent breaking old code.&lt;/p&gt;
&lt;p&gt;I am posting this question both as a feature request and a central place for people to vote.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13366/virtual-thread-executor-for-core-async</guid>
<pubDate>Sun, 08 Oct 2023 23:30:28 +0000</pubDate>
</item>
<item>
<title>Fix for the ASYNC-163 - Off by two error in pipeline-async</title>
<link>https://ask.clojure.org/index.php/12394/fix-for-the-async-163-off-by-two-error-in-pipeline-async</link>
<description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;I've been working on a fix for the &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/ASYNC-163&quot;&gt;ASYNC-163&lt;/a&gt; bug, and I think I've got a robust solution that doesn't require many changes to the &lt;code&gt;pipeline*&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;I'm new to contributing to Clojure, so I'm a bit unsure about the process, though I've read about it on the clojure.org website. There's already an existing ticket for the problem, which I've linked above, however, it was closed as &quot;won't fix&quot;, and I don't have a Jira account to comment there and send a patch, so I've decided to post here.&lt;/p&gt;
&lt;p&gt;After studying the source code of the &lt;code&gt;pipeline*&lt;/code&gt; function, I've understood the whole process of how jobs are passed between go-threads and channels and found a simple fix, that requires adding one more channel to synchronize job-producer and result-consumer threads.&lt;br&gt;
I have a more in-depth explanation of the bug in my blog. It is rather long and convoluted, so I think it would be best if I will not repeat myself here, making this question unnecessarily long and much harder to understand. The explanation is available &lt;a rel=&quot;nofollow&quot; href=&quot;https://andreyorst.gitlab.io/posts/2022-11-21-clojures-coreasync-pipeline-async-off-by-two-error-explained/#explanation&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;I'm attaching a patch here, feel free to point me in the right direction if this place is not for this type of question. I've tested the in the REPL with various scenarios and in one of my projects, that uses regular &lt;code&gt;pipeline-async&lt;/code&gt;, it works correctly. In addition, it passes tests in the &lt;code&gt;core.async&lt;/code&gt; library, which I ran with the &lt;code&gt;lein test&lt;/code&gt; command.&lt;/p&gt;
&lt;p&gt;Patch: &lt;a rel=&quot;nofollow&quot; href=&quot;https://andreyorst.gitlab.io/0001-fix-ASYNC-163.patch&quot;&gt;https://andreyorst.gitlab.io/0001-fix-ASYNC-163.patch&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;At the moment I have some problems with running CLJS tests with or without my patch for the async.cljs file, but once I figure out the problem I'll post an updated patch, for both JVM and CLJS runtimes&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit: Nov 25 2022&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Patch v2: &lt;a rel=&quot;nofollow&quot; href=&quot;https://andreyorst.gitlab.io/0001-fix-ASYNC-163-2.patch&quot;&gt;https://andreyorst.gitlab.io/0001-fix-ASYNC-163-2.patch&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This patch includes the same fix for async.cljs, though I wasn't able to run tests for some reason - I get the &lt;code&gt;Uncaught TypeError: process.on is not a function&lt;/code&gt; error in the browser. Not sure what I'm missing, the project's readme doesn't mention any requirements besides building with lein and opening the HTML file. But the fix is essentially the same, so it should work fine.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit Dec 08 2022&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I've put the fixed version of &lt;code&gt;pipeline*&lt;/code&gt; into a library &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/andreyorst/pipeline-extras&quot;&gt;pipeline-extras&lt;/a&gt;. It also has unordered versions of all pipelines, which should have higher throughput because the conveyer doesn't stop if any of the tasks take longer to complete than the other ones.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12394/fix-for-the-async-163-off-by-two-error-in-pipeline-async</guid>
<pubDate>Tue, 22 Nov 2022 17:48:51 +0000</pubDate>
</item>
<item>
<title>core.async readme oversight</title>
<link>https://ask.clojure.org/index.php/12372/core-async-readme-oversight</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/96cb49e15b046e17e5b73eee5f9ce61ab44883ba/README.md?plain=true#L17&quot;&gt;https://github.com/clojure/core.async/blob/96cb49e15b046e17e5b73eee5f9ce61ab44883ba/README.md?plain=true#L17&lt;/a&gt; refers to 1.5, while the latest at the moment is 1.6&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12372/core-async-readme-oversight</guid>
<pubDate>Wed, 09 Nov 2022 10:55:02 +0000</pubDate>
</item>
<item>
<title>core.async test hangs on single-cpu system</title>
<link>https://ask.clojure.org/index.php/12039/core-async-test-hangs-on-single-cpu-system</link>
<description>&lt;p&gt;When running the core.async testsuite on a single-cpu system, the tests hang at the ASYNC-127 test.&lt;/p&gt;
&lt;p&gt;I noticed this when attempting to run the tests on the Debian package building infrastructure and was also able to reproduce the issue locally.&lt;/p&gt;
&lt;p&gt;Our current workaround is to simply &lt;a rel=&quot;nofollow&quot; href=&quot;https://salsa.debian.org/clojure-team/core-async-clojure/-/blob/debian/main/debian/patches/0002-Skip-test-assertions-which-hang-in-single-cpu-env.patch&quot;&gt;skip that test altogether&lt;/a&gt;.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12039/core-async-test-hangs-on-single-cpu-system</guid>
<pubDate>Wed, 06 Jul 2022 14:09:21 +0000</pubDate>
</item>
<item>
<title>Easy to hang the current thread with `(a/&lt;!! (a/map f chs))` when `chs` is empty</title>
<link>https://ask.clojure.org/index.php/10652/easy-to-hang-the-current-thread-with-map-chs-when-chs-is-empty</link>
<description>&lt;p&gt;This code&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(a/&amp;lt;!! (a/map vector []))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will hang the current thread.&lt;/p&gt;
&lt;p&gt;Would be nice if there was a check for the empty &lt;code&gt;chs&lt;/code&gt; argument to &lt;code&gt;a/map&lt;/code&gt; or at least a docstring mention, given how easy it is to fall into this trap by using e.g. &lt;code&gt;filter&lt;/code&gt; in place of the &lt;code&gt;[]&lt;/code&gt; above.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10652/easy-to-hang-the-current-thread-with-map-chs-when-chs-is-empty</guid>
<pubDate>Mon, 24 May 2021 16:09:20 +0000</pubDate>
</item>
<item>
<title>Strategies for diagnosing core.async code that is unexpectedly blocking the main thread?</title>
<link>https://ask.clojure.org/index.php/10190/strategies-diagnosing-async-unexpectedly-blocking-thread</link>
<description>&lt;p&gt;I'm new to core.async (and CSP more generally) and struggling to find good debugging strategies. In particular, I frequently fail to diagnosis which part of the code is infinitely blocking the main thread. I'll give a particular example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(deftest passing-test
  (let [c (async/to-chan! [2 1 0 5 4])]
    (is (= [2 1 0 5 4]
           (async/&amp;lt;!! (async/into [] c))))))


(deftest hanging-test
  (let [[e o] (-&amp;gt;&amp;gt; (async/to-chan! [2 1 0 5 4])
                   (async/split even?))]
    (is (= [2 0 4]
           (async/&amp;lt;!! (async/into [] e))))
    (is (= [1 5]
           (async/&amp;lt;!! (async/into [] o))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first test passes and does not block the main thread. The second test hangs forever. The only difference is the addition of &lt;code&gt;async/split&lt;/code&gt; to route even and odd integers to their respective channels.&lt;/p&gt;
&lt;p&gt;My specific questions are as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What explains the difference between the first and second tests with respect to blocking the main thread?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What are some strategies to debugging core.async code that is unexpectedly blocking the main thread?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is the best way to write unit tests for code that creates and manipulates channels? Is &lt;code&gt;(async/&amp;lt;!! (async/into [] o))&lt;/code&gt; a reasonable way to collect the values flowing through a channel into a collection?&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10190/strategies-diagnosing-async-unexpectedly-blocking-thread</guid>
<pubDate>Sun, 14 Feb 2021 21:07:06 +0000</pubDate>
</item>
<item>
<title>How to do a blocking put on a channel ?</title>
<link>https://ask.clojure.org/index.php/9924/how-to-do-a-blocking-put-on-a-channel</link>
<description>&lt;p&gt;I am getting the  following error&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;No more than 1024 pending takes are allowed on a single channel&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;However, I though that if i defined a channel with a specifed size , the puts would  block.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def event-chan (chan 10))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am calling this in a loop&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(&amp;gt;!! event-chan evt)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My expectation is that it would block is there were pending 10 items in the channel .. however does not seem to be happening. My code is reading a fifo queue in a database and proceesiing it. it seems to not block even if the items are pending in the channel&lt;/p&gt;
&lt;p&gt;  edit: updated to copy paste the full actual code.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn process-edn [{:keys [data code]}]
; lots db processing code here
)
  
(def event-chan (chan 10))
  
(defn eat-now-or-later[evt]
    (if ( = (evt :code) :loadevt)
        (do (println &quot;sync processing load event &quot;)
            (process-edn evt))
        (&amp;gt;!! event-chan evt)
      ))
  
  (defn async-deque [shutdown?]
    (time! dq-call-processing-time
           (let [k-t (ftup/from commons/*JOB_FIFO_EVENT_QUEUE*)
                 fdb (cfdb/select-api-version cfdb/clj-fdb-api-version)]
             (go (while true (process-edn (&amp;lt;! event-chan))))

             (loop[evt (with-open [^Database db (cfdb/open fdb)] (fifo/dequeue db k-t))]
              
              (if (or (shutdown?)  (nil? evt)) 0
                  
                  (do                   
                   (eat-now-or-later evt)  
                   (recur (with-open [^Database db (cfdb/open fdb)] (fifo/dequeue db k-t))))
                  )
              )))
    (ptasks/print-stats))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above is the function definition. I am calling this function from the daemon code below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns dqdaemon.core
  (:require [shutdown.core :as shutdown])
  (:require [com.videocloudmanager.petikaa.dequeue-tasks :as dqt])
 )

;; A crude approximation of your application's state.
(def state (atom {}))

(defn shutdown?[] (false? (:running @state)))

(defn init [args]
  (swap! state assoc :running true)
  (shutdown/add-hook! ::descriptive-name #(do
                                            (swap! state assoc :running false)         
                                            (println &quot;It's about to go down!&quot;)))
  )

(defn start []
  (while (:running @state)
    (println &quot;tick&quot;)
     (dqt/async-deque shutdown?)
    (Thread/sleep 2000)))


;; Enable command-line invocation
(defn -main [&amp;amp; args]
  (init args)
  (start))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   &lt;strong&gt;Update:&lt;/strong&gt;&lt;br&gt;
 I understand that this is not an issue with blocking puts. It is because my code is creating unlimited goloops.&lt;/p&gt;
&lt;p&gt;This code is being called in a loop and the parent method of this loop , async-dequ, is being called in a forever loop. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(go (while true (process-edn (&amp;lt;! event-chan)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am moving this code out of the loop-recur and into the main method  to initialize when the daemon is started&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9924/how-to-do-a-blocking-put-on-a-channel</guid>
<pubDate>Tue, 08 Dec 2020 19:43:21 +0000</pubDate>
</item>
<item>
<title>documentation issues on clojurescript promises interop</title>
<link>https://ask.clojure.org/index.php/9609/documentation-issues-on-clojurescript-promises-interop</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurescript.org/guides/promise-interop&quot;&gt;https://clojurescript.org/guides/promise-interop&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;this is given as the way to setup core.async for &amp;lt;p!  : &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(:require
   [cljs.core.async :refer [go]]
   [cljs.core.async.interop :refer-macros [&amp;lt;p!]])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are using current shadow-cljs and node target, and we find that this recipe leaves 'go' exposed as a function, not a macro.  &lt;/p&gt;
&lt;p&gt;replacing with :refer-macros [go] fixes the issue&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9609/documentation-issues-on-clojurescript-promises-interop</guid>
<pubDate>Wed, 16 Sep 2020 20:35:21 +0000</pubDate>
</item>
<item>
<title>(CLJS) finally-block prevents exception throw in go-block</title>
<link>https://ask.clojure.org/index.php/9587/cljs-finally-block-prevents-exception-throw-in-go-block</link>
<description>&lt;p&gt;ClojureScript 1.10.520, could not reproduce in Clojure. Reproduced in &lt;code&gt;core.async&lt;/code&gt; 1.3.610 and 1.1.582, not reproducible in 1.0.567.&lt;/p&gt;
&lt;p&gt;Looks the same as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/ASYNC-198?focusedCommentId=12026&quot;&gt;https://clojure.atlassian.net/browse/ASYNC-198?focusedCommentId=12026&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns app.main
  (:require [clojure.core.async :as a]))

(a/go
  (try
    (prn :ret
         (try
           (throw (ex-info &quot;expected&quot; {}))

           (catch js/Error e
             (prn :catch1)
             (throw e))

           (finally
             (prn :finally))))

    (catch js/Error _e
      (prn :catch2))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Expected:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:catch1
:finally
:catch2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Actual:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:catch1
:finally
:ret #error {:message &quot;expected&quot;, :data {}}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9587/cljs-finally-block-prevents-exception-throw-in-go-block</guid>
<pubDate>Mon, 07 Sep 2020 12:47:54 +0000</pubDate>
</item>
<item>
<title>Add additional arity to the ex-handler [core.async]</title>
<link>https://ask.clojure.org/index.php/9257/add-additional-arity-to-the-ex-handler-core-async</link>
<description>&lt;p&gt;I find it limiting that &lt;code&gt;ex-handler&lt;/code&gt; for &lt;code&gt;async/pipeline&lt;/code&gt;(&lt;code&gt;-blocking&lt;/code&gt;) accepts an exception only, but not the value for which that exception occurred. Another arity &lt;code&gt;(fn [ex v])&lt;/code&gt; would be useful for use cases such as retrying, better error reporting etc. I guess it could be supported in a backward-compatible way via reflection arity checking (e.g. &lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/a/1813967&quot;&gt;https://stackoverflow.com/a/1813967&lt;/a&gt;).&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9257/add-additional-arity-to-the-ex-handler-core-async</guid>
<pubDate>Mon, 20 Apr 2020 22:53:25 +0000</pubDate>
</item>
<item>
<title>Add support for &lt;!! in cljs</title>
<link>https://ask.clojure.org/index.php/9136/add-support-for-in-cljs</link>
<description>&lt;p&gt;Is there a good reason why &lt;code&gt;&amp;lt;!!&lt;/code&gt; isn't supported in cljs? If there isn't, wouldn't it be great to add support for &lt;code&gt;&amp;lt;!!&lt;/code&gt;?&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9136/add-support-for-in-cljs</guid>
<pubDate>Sat, 29 Feb 2020 20:24:26 +0000</pubDate>
</item>
<item>
<title>core.async bug: &quot;No more than 1024 pending takes are allowed&quot; assertion involving 'alt!'</title>
<link>https://ask.clojure.org/index.php/9025/core-async-more-pending-takes-allowed-assertion-involving</link>
<description>&lt;p&gt;We encountered a thorny problem with &lt;code&gt;core.async&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;In some situations &quot;No more than 1024 pending takes are allowed&quot; is raised in an async-dispatch thread, even though there are actually only 1024 pending takes.&lt;br&gt;
That situation can be triggered quickly with the following code:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(dotimes [_ 5000]&lt;br&gt;
  ;; - start 1024 threads that all alt! on a common channel (ch) and on an individual channel (x)&lt;br&gt;
  ;; - the common channel remains 'empty' all the time&lt;br&gt;
  ;; - wakeup all theads twice via the x channel, which makes them loop.&lt;br&gt;
  ;; - this quickly raises multiple 'No more than 1024 pending takes are allowed on a single channel.' assertions in an async-dispatch thread.&lt;br&gt;
  (let [ch (async/chan)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    threads clojure.core.async.impl.protocols/MAX-QUEUE-SIZE
    wakeups 2
    x-chans
    (mapv (fn [n]
            (let [x (async/chan)]
              (async/go-loop []
                (async/alt!
                  ch nil
                  x ([_] (recur))))
              x))
          (range threads))]
(doseq [x x-chans]
  (dotimes [n wakeups]
    (async/&amp;gt;!! x 42)))
(async/close! ch)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Environment:&lt;br&gt;
Mac OS, JDK 8, Clojure 1.10.0, core-async 0.6.532&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9025/core-async-more-pending-takes-allowed-assertion-involving</guid>
<pubDate>Mon, 13 Jan 2020 08:24:38 +0000</pubDate>
</item>
<item>
<title>core.async pipeline arguments order</title>
<link>https://ask.clojure.org/index.php/8968/core-async-pipeline-arguments-order</link>
<description>&lt;p&gt;I'm curious about why in the 3 &lt;code&gt;pipeline*&lt;/code&gt; functions in core.async, the &lt;code&gt;to&lt;/code&gt; argument is expected before the &lt;code&gt;from&lt;/code&gt; argument. Looks like originally, with the &lt;code&gt;pipe&lt;/code&gt; function, the order was the opposite, but when the &lt;code&gt;pipeline&lt;/code&gt; functions where added, there was a reason to swap the order. &lt;/p&gt;
&lt;p&gt;There is also a &lt;code&gt;todo&lt;/code&gt; on the code to change arguments order for &lt;code&gt;pipe&lt;/code&gt;:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/39488d33b4933ef3eb4c4aac485ad21ac3c78825/src/main/clojure/clojure/core/async.clj#L574&quot;&gt;https://github.com/clojure/core.async/blob/39488d33b4933ef3eb4c4aac485ad21ac3c78825/src/main/clojure/clojure/core/async.clj#L574&lt;/a&gt; &lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8968/core-async-pipeline-arguments-order</guid>
<pubDate>Thu, 26 Dec 2019 12:47:08 +0000</pubDate>
</item>
<item>
<title>A literal meta in cljs.core.async</title>
<link>https://ask.clojure.org/index.php/8966/a-literal-meta-in-cljs-core-async</link>
<description>&lt;p&gt;Is it a bug or a technical impossibility to implement a literal meta in cljs version of core.async?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns clojurescript-example
  (:require
   [cljs.core.async :as a]))

(let [x (a/go ^:foo [:x])]
  (a/go
    (prn (meta (a/&amp;lt;! x))))) ;; nil
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;(ns clojure-example
  (:require
   [clojure.core.async :as a]))

(let [x (a/go ^:foo [:x])]
  (a/go
    (prn (meta (a/&amp;lt;! x))))) ;; {:foo true}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8966/a-literal-meta-in-cljs-core-async</guid>
<pubDate>Tue, 24 Dec 2019 20:02:54 +0000</pubDate>
</item>
<item>
<title>where is the blocking operation?</title>
<link>https://ask.clojure.org/index.php/8805/where-is-the-blocking-operation</link>
<description>&lt;p&gt;This change &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/commit/3429e3e1f1d49403bf9608b36dbd6715ffe4dd4f&quot;&gt;https://github.com/clojure/core.async/commit/3429e3e1f1d49403bf9608b36dbd6715ffe4dd4f&lt;/a&gt; changes the number of threads created by a pipeline pretty significantly(0 new threads vs N new threads) and removes the only difference between pipeline and pipeline-blocking while maintaining the separate existence , which seems odd, so I am trying to understand the purpose of it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I have seen Alex say he found a bug with a blocking operation in pipeline and fixed it by making pipeline and pipeline-blocking act the same, so I think that refers to this commit.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What I don't understand is where the blocking operation is in the old version. The only thing I see that might be it is the use of &lt;code&gt;&amp;gt;!!&lt;/code&gt; in the process function, but it is called once on a channel with a buffer of size 1, that is created immediately before and closed right after, so there is no way other operations can be pending on it, so it might as well be a &lt;code&gt;put!&lt;/code&gt; which never blocks. &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;if #1 really is the reason behind the commit, I don't understand it in light of #2, if #1 is not the reason behind the commit does anyone know what it is?&lt;/p&gt;
&lt;p&gt;Is #2 straight up wrong? Is there some way that the &lt;code&gt;&amp;gt;!!&lt;/code&gt; can block given a non-shared channel with space in its buffer? &lt;/p&gt;
&lt;p&gt;Is this about blocking xforms? I thought that was caveat emptor. &lt;/p&gt;
&lt;p&gt;Will pipeline be marked as deprecated since it now has the same behavior as pipeline-blocking?&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8805/where-is-the-blocking-operation</guid>
<pubDate>Thu, 31 Oct 2019 22:54:34 +0000</pubDate>
</item>
<item>
<title>Is alt!! actually not completing put operations when the channel closes?</title>
<link>https://ask.clojure.org/index.php/8610/alt-actually-not-completing-operations-when-channel-closes</link>
<description>&lt;p&gt;It seems to me that &lt;code&gt;alt!!&lt;/code&gt; does complete put operations only when the channel is already closed from the beginning, but not when the channel is closed while alt!! is waiting. That is unlike read operations, which complete with a nil value.&lt;/p&gt;
&lt;p&gt;Is that an intended behaviour? If so, that is quite 'unfavourable' for obvious reasons. It should at least be marked with a big warning sign in the docs then.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8610/alt-actually-not-completing-operations-when-channel-closes</guid>
<pubDate>Tue, 17 Sep 2019 09:04:58 +0000</pubDate>
</item>
<item>
<title>Any plans for core.async with Project Loom?</title>
<link>https://ask.clojure.org/index.php/8196/any-plans-for-core-async-with-project-loom</link>
<description>&lt;p&gt;I was wondering if there are any plans to revamp/rewrite core.async now that Project Loom seems well underway....  &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.reddit.com/r/Clojure/comments/ch90sh/fibers_and_continuations_in_clojure_with_project/&quot;&gt;https://www.reddit.com/r/Clojure/comments/ch90sh/fibers_and_continuations_in_clojure_with_project/&lt;/a&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8196/any-plans-for-core-async-with-project-loom</guid>
<pubDate>Fri, 26 Jul 2019 07:32:12 +0000</pubDate>
</item>
<item>
<title>Cljs timeout timers skiplist is naive linked list</title>
<link>https://ask.clojure.org/index.php/292/cljs-timeout-timers-skiplist-is-naive-linked-list</link>
<description>The skip list for the cljs timers has a bug which is readily apparent: a loop without a recur:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{code:java}&lt;br /&gt;
(let [x (skip-list-node k v (make-array new-level))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(loop [i 0]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(when (&amp;lt;= i level)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [links (.-forward (aget update i))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(aset (.-forward x) i (aget links i))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(aset links i x)))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is from the `put` function. This ordinarily would be a terrible bug except that the link at 0 is just the naive linked-list link and it omits the &amp;quot;skips&amp;quot; of the skip list. A trivial patch fixes this to recur from the when form.&lt;br /&gt;
&lt;br /&gt;
This has an implication to the ceilingEntry function however:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{code:java}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(ceilingEntry [coll k]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(loop [x header level level]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if-not (neg? level)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [nx (loop [x x]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [x' (when (&amp;lt; level (alength (.-forward x)))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(aget (.-forward x) level))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(when-not (nil? x')&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if (&amp;gt;= (.-key x') k)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x'&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(recur x')))))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if-not (nil? nx)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(recur nx (dec level))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(recur x (dec level))))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(when-not (identical? x header)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This function allows to &amp;quot;overshoot&amp;quot; the key you are searching for, presumably finding the &amp;quot;next&amp;quot; node. With a simple linked list this is fine and well-defined. However, with a skip list, this allows for drastic and non-deterministic overshooting depending on how big a skip is.&lt;br /&gt;
&lt;br /&gt;
This needs to be patched to only overshoot when in the lowest linked list and not in any of the skip list links.</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/292/cljs-timeout-timers-skiplist-is-naive-linked-list</guid>
<pubDate>Mon, 17 Jun 2019 13:10:52 +0000</pubDate>
</item>
<item>
<title>(CLJS) cljs alts! not non-deterministic</title>
<link>https://ask.clojure.org/index.php/298/cljs-cljs-alts-not-non-deterministic</link>
<description>In cljs, {{clojure.core.async/random-array}}'s shuffle was incorrect, leading it to always return \[1 0\] for arg n=2. This breaks the promise that alts! is non-deterministic w.r.t. op selection by always trying the second element first. Additionally, the first op is never chosen first for alts! of any size N&amp;gt;1.&lt;br /&gt;
&lt;br /&gt;
Use goog.array.shuffle to do the shuffle instead. (This API is also used by cljs.core/shuffle)&lt;br /&gt;
&lt;br /&gt;
New implementation passes tests and behaves better:&lt;br /&gt;
&lt;br /&gt;
{code:java}&lt;br /&gt;
&lt;br /&gt;
cljs.user=&amp;gt; (frequencies (take 10000 (map vec (repeatedly #(a/random-array 2)))))&lt;br /&gt;
WARNING: var: cljs.core.async/random-array is not public at line 1 &amp;lt;cljs repl&amp;gt;&lt;br /&gt;
{[0 1] 4964, [1 0] 5036}&lt;br /&gt;
&lt;br /&gt;
cljs.user=&amp;gt; (frequencies (take 10000 (map vec (repeatedly #(clojure.core.async/random-array 3)))))&lt;br /&gt;
WARNING: var: cljs.core.async/random-array is not public at line 1 &amp;lt;cljs repl&amp;gt;&lt;br /&gt;
{[0 1 2] 1720, [1 2 0] 1679, [2 0 1] 1669, [0 2 1] 1573, [1 0 2] 1682, [2 1 0] 1677}&lt;br /&gt;
cljs.user=&amp;gt; (pp)&lt;br /&gt;
{[0 1 2] 1720,&lt;br /&gt;
&amp;nbsp;[1 2 0] 1679,&lt;br /&gt;
&amp;nbsp;[2 0 1] 1669,&lt;br /&gt;
&amp;nbsp;[0 2 1] 1573,&lt;br /&gt;
&amp;nbsp;[1 0 2] 1682,&lt;br /&gt;
&amp;nbsp;[2 1 0] 1677}&lt;br /&gt;
nil&lt;br /&gt;
&lt;br /&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/298/cljs-cljs-alts-not-non-deterministic</guid>
<pubDate>Tue, 11 Jun 2019 04:28:02 +0000</pubDate>
</item>
<item>
<title>Add a closable-timeout function that always return a fresh channel</title>
<link>https://ask.clojure.org/index.php/297/closable-timeout-function-that-always-return-fresh-channel</link>
<description>Hello,&lt;br /&gt;
&lt;br /&gt;
This is my first patch in a core Clojure project. I will try to be as clear and verbose in the problem statement,&lt;br /&gt;
the solution the patch brings and the value proposition.&lt;br /&gt;
&lt;br /&gt;
h3. Problem:&lt;br /&gt;
&lt;br /&gt;
The {{timeout}} function returns a channel that maybe unsafe to call {{close!}} on. It's because in an application that creates&lt;br /&gt;
several timeout channels very closely in time, the newly created timeout channels will in fact be the previously created channels&lt;br /&gt;
if the call to `timeout` happens less than {{clojure.core.async.impl.timers/TIMEOUT_RESOLUTION_MS}} after the previous ones (currently 10 ms).&lt;br /&gt;
&lt;br /&gt;
It means that manually closing a channel causes code that creates new ones shortly after will in fact retrieves a closed channel.&lt;br /&gt;
Taking from it, using {{alt!}} etc hence exhibits unwanted behavior.&lt;br /&gt;
&lt;br /&gt;
It happened to us when we tried to create a safer take in the context of a high traffic website (10+ millions page views/day), which uses timeout channels&lt;br /&gt;
against normal channels for calling external services and ensures that no go block is indefinitely waiting for a channel to clause.&lt;br /&gt;
&lt;br /&gt;
Here's the code, to give more context to the discussion:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defmacro &amp;lt;?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;quot;Safer &amp;lt;! (take), that times out to avoid waiting infinitely&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;[port]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;`(let [timeout-ch# (async/timeout 120000) ;; 2 minutes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;val# (as/alt!&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;timeout-ch# :timeout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;~port ([v#] v#))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(cond&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(instance? Throwable val#) (throw val#)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(= val# :timeout) (throw (ex-info &amp;quot;A timeout occur in a channel async&amp;quot; {}))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:else val#)))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using timeout channels (with long timeouts of 2 minutes) without closing them solved our core problem (too many TCP sockets in CLOSE_WAIT state)&lt;br /&gt;
but immediately caused the application to use approximately 10%+ CPU and way more memory than before.&lt;br /&gt;
&lt;br /&gt;
After analyzing the problem, we concluded that leaving the timeout channels as is resulted in them continuously executing the code&lt;br /&gt;
that checks if their time had passed, even if the &amp;quot;safe take&amp;quot; go block had returned. And most of the time, it's not the external&lt;br /&gt;
services that time out or fail, they just work and respond fast.&lt;br /&gt;
&lt;br /&gt;
So for us, closing (with {{close!}}) the timeout channels immediately after the {{alt!}} failed because of the {{TIMEOUT_RESOLUTION_MS}} sharing.&lt;br /&gt;
After the first {{&amp;lt;?}}, subsequent calls to {{&amp;lt;?}} that happens shortly after would fails since previous timeout channels were reused and already closed.&lt;br /&gt;
In the context of a web application it's very common to do several requests to external services (and coordinates them with core.async)&lt;br /&gt;
before being able to send the response. I believe many other kind of applications would behave the same way.&lt;br /&gt;
&lt;br /&gt;
h3. Solution:&lt;br /&gt;
&lt;br /&gt;
Our solution consists in creating another timeout function that:&lt;br /&gt;
- doesn't try to reuse channels created in the {{TIMEOUT_RESOLUTION_MS}} window&lt;br /&gt;
- always returns a fresh channel&lt;br /&gt;
- doesn't add the newly created channel to the {{^ConcurrentSkipListMap timeouts-map}} to avoid collaboration with other normal timeout channels.&lt;br /&gt;
&lt;br /&gt;
Current name is {{closable-timeout}}, to be validated. It could be {{safe-timeout}} or something else.&lt;br /&gt;
&lt;br /&gt;
Please note that we already implemented and deployed the solution to production. We measured precisely the impact and are&lt;br /&gt;
confident that this is potentially a good patch that the wider Clojure community would benefit from. What we measured:&lt;br /&gt;
&lt;br /&gt;
- When using the normal timeout channels (without closing them manually), memory usage (committed heap) reached our maximum level very quickly (9GB)&lt;br /&gt;
on all our 4 machines and stabilized at this level. Our understand is that it's because each of our requests would create&lt;br /&gt;
on average 4 timeout channels that would be garbage collected at least 2 minutes after.&lt;br /&gt;
During this 2 minutes window we would get lots of requests, so lot of garbage would be be created before being collected.&lt;br /&gt;
The garbage collector (G1) would use on average 3-4% CPU time working (young generation).&lt;br /&gt;
&lt;br /&gt;
- When using our custom timeout channels, memory usage (committed heap) immediately returned to normal (2-5GB) depending on the machine&lt;br /&gt;
and stabilized at this level. We believe that it's because garbage channels are collected much faster so they don't pollute the heap&lt;br /&gt;
and create much less data to collect for the GC. CPU time spent in collection decreased back to our normal levels of operation (less than 0.5%).&lt;br /&gt;
Our understanding of G1 is that one of its specialty is doing much more frequent garbage collections of small amount of data,&lt;br /&gt;
and doing so in a much more efficient way than previous GC. Being able to close timeout channels manually allowed our application&lt;br /&gt;
to align with G1 behaviour closely.&lt;br /&gt;
&lt;br /&gt;
The patch includes a test that demonstrates the problem, as well as another test that just use instead the new {{closable-timeout}} channel&lt;br /&gt;
that doesn't exhibit the problem.&lt;br /&gt;
&lt;br /&gt;
h3. Value proposition:&lt;br /&gt;
&lt;br /&gt;
Why submitting a patch while it can be done in user-space? Because to implement this functionality we had to rely on the&lt;br /&gt;
{{clojure.core.async.impl.timers}} namespace which should be an implementation detail, and also had to add the channel&lt;br /&gt;
to the {{^DelayQueue timeouts-queue}} from the same namespace by using the {{@#'}} trick (like this {{(def ^DelayQueue async-timeouts-queue @#'clojure.core.async.impl.timers/timeouts-queue)}}).&lt;br /&gt;
Hence any refactoring of core.async could break our code or anyone doing the same thing.&lt;br /&gt;
&lt;br /&gt;
h3. Things to consider:&lt;br /&gt;
&lt;br /&gt;
- We haven't tested with other garbage collectors, nor on the GraalVM.&lt;br /&gt;
- We didn't change at all the current timeout implementation, understand that this {{TIMEOUT_RESOLUTION_MS}} trick is a performance optimization.&lt;br /&gt;
- We added a note in the docstring of the normal timeout about the fact that normal timeout channels are unsafe to close manually.&lt;br /&gt;
- We wonder if it would be better, for normal timeout channels to throw an Exception when calling {{close!}} on them since it's unsafe.&lt;br /&gt;
- I haven't given lots of thoughts about CLJS core.async, since this repo contains only Clojure code but both CLJ and CLJS tests (no idea how the thing works...)&lt;br /&gt;
&lt;br /&gt;
PS: I have no idea if I should have run some script from the {{script}} folder.&lt;br /&gt;
PS2: Not sure if this is an enhancement or a defect, but as it bit us hard I chose defect.&lt;br /&gt;
PS3: I'm open to all comments, no string attached.</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/297/closable-timeout-function-that-always-return-fresh-channel</guid>
<pubDate>Mon, 03 Dec 2018 17:22:10 +0000</pubDate>
</item>
<item>
<title>let in go block leaks memory</title>
<link>https://ask.clojure.org/index.php/603/let-in-go-block-leaks-memory</link>
<description>&lt;p&gt;When a let binding gets used across a blocking operation, the binding leaks out of the let.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
  (async/go-loop []&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [msg (async/&amp;lt;! in-ch)]
  (if msg
    (let [stuff (vec (range 1 100000))]
      (async/&amp;lt;! out-ch stuff)
      (println stuff)
      (recur))
    (recur))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The {{stuff}} binding gets stuck into the the state-machine state. This persists across the {{recur}}, until the binding is next encountered.&lt;/p&gt;
&lt;p&gt;(In our case, a few GBs had accumuled by that time.)&lt;/p&gt;
&lt;p&gt;Ideally, the fields in the state that represent local variables would be nulled when the variables go out of scope.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/603/let-in-go-block-leaks-memory</guid>
<pubDate>Tue, 13 Nov 2018 10:25:49 +0000</pubDate>
</item>
<item>
<title>can't assign instance fields in go blocks</title>
<link>https://ask.clojure.org/index.php/593/cant-assign-instance-fields-in-go-blocks</link>
<description>&lt;p&gt;IOC doesn't properly handle &lt;code&gt;set!&lt;/code&gt;. The following snippet fails to compile because &lt;code&gt;set!&lt;/code&gt; is treated like a function call, evaluating field access first instead of treating the whole form as a field instance assignment.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(a/go (set! (.-gridx (java.awt.GridBagConstraints.)) (a/&amp;lt;! (a/go 0))))&lt;/code&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/593/cant-assign-instance-fields-in-go-blocks</guid>
<pubDate>Tue, 06 Nov 2018 11:08:40 +0000</pubDate>
</item>
<item>
<title>go ignores async code in letfn body</title>
<link>https://ask.clojure.org/index.php/350/go-ignores-async-code-in-letfn-body</link>
<description>&lt;p&gt;The following snippet fails because &lt;code&gt;&amp;lt;!&lt;/code&gt; is outside of {{go}} boundaries.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(let [port (a/chan)]&lt;br&gt;
  (a/go&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(letfn [(my-even? [n] (if (zero? n) true (my-odd? (dec n))))
        (my-odd? [n] (if (zero? n) false (my-even? (dec n))))]
  (my-even? (a/&amp;lt;! port)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Async code in {{letfn}} body should be rewritten by the {{go}} macro, given all bound functions can be properly initialized when the body starts.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/350/go-ignores-async-code-in-letfn-body</guid>
<pubDate>Tue, 16 Oct 2018 13:38:59 +0000</pubDate>
</item>
<item>
<title>an exception caught in a finally block swallows the exception of the outer try</title>
<link>https://ask.clojure.org/index.php/295/exception-caught-finally-block-swallows-the-exception-outer</link>
<description>The inner try exception handling clears the exception status of the outer try, making it return successfully instead of rethrowing.&lt;br /&gt;
In the following snippet, prn is executed althought it should be dead code.&lt;br /&gt;
&lt;br /&gt;
(let [chan (a/chan)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;npe! nil]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(a/go&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(try (npe!)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(finally&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(try (a/&amp;gt;! chan (npe!))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(catch NullPointerException _))))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(prn &amp;quot;this is fine.&amp;quot;)))&lt;br /&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/295/exception-caught-finally-block-swallows-the-exception-outer</guid>
<pubDate>Sun, 23 Sep 2018 16:59:21 +0000</pubDate>
</item>
<item>
<title>some locals are not cleared in go blocks</title>
<link>https://ask.clojure.org/index.php/592/some-locals-are-not-cleared-in-go-blocks</link>
<description>&lt;p&gt;Running this code eventually throws OOME :&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(let [c (a/chan)]&lt;br&gt;
  (a/go (while (a/&amp;lt;! c)))&lt;br&gt;
  (a/go&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(when-some [xs (range)]
  (doseq [x xs]
    (a/&amp;gt;! c x)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This one (with {{let}} instead of {{when-some}}) works fine :&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(let [c (a/chan)]&lt;br&gt;
  (a/go (while (a/&amp;lt;! c)))&lt;br&gt;
  (a/go&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [xs (range)]
  (doseq [x xs]
    (a/&amp;gt;! c x)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;In the former, the range seq is stored on the heap (in go block's state array) and retained for the whole doseq iteration, althought it's not needed anymore after loop initialization.&lt;br&gt;
In the latter, the range seq is stored on the stack so the compiler is able to perform its local clearing magic.&lt;/p&gt;
&lt;p&gt;This behavior is likely to happen for every value spanning across multiple ssa blocks.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/592/some-locals-are-not-cleared-in-go-blocks</guid>
<pubDate>Thu, 30 Aug 2018 13:17:42 +0000</pubDate>
</item>
<item>
<title>pipeline does not stop consuming from when to is closed</title>
<link>https://ask.clojure.org/index.php/594/pipeline-does-not-stop-consuming-from-when-to-is-closed</link>
<description>The docs for pipeline say &amp;quot;Will stop consuming the from channel if the to channel closes.&amp;quot; however currently the go block that is reading results and putting to the to channel does a &amp;gt;!, and checks the return value to stop trying to output the current output value, but then goes ahead and tries to process the next output anyways. Thus, if the to channel is closed, the pipeline will continue reading, processing, and attempting to spit values at the to channel without stop. &lt;br /&gt;
&lt;br /&gt;
Also, even if it did stop, some number of values will already have been read from the from channel (1 may be in-process in the output go block, N may be in the results channel, and N may be parked in flight in process go blocks).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(require '[clojure.core.async :as a])&lt;br /&gt;
(let [from (a/to-chan (range 100))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;to (a/chan 1)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(a/pipeline 1 to (map #(doto % println)) from)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(a/close! to))&lt;br /&gt;
;; prints 0...99&lt;br /&gt;
;; Expect: should print no more than 4 items (1 in to, 1 in out go, 1 in results chan, 1 in process go)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Proposed:* One option would be to change the doc string and not promise this behavior. Another would be to cause the close to flow back through the pipeline structure, shutting it all down.</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/594/pipeline-does-not-stop-consuming-from-when-to-is-closed</guid>
<pubDate>Thu, 17 May 2018 17:26:02 +0000</pubDate>
</item>
<item>
<title>(CLJS) Cannot use (js-debugger) in go block</title>
<link>https://ask.clojure.org/index.php/598/cljs-cannot-use-js-debugger-in-go-block</link>
<description>To see the error, run the following:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version &amp;quot;1.10.238&amp;quot;}org.clojure/core.async {:mvn/version &amp;quot;0.4.474&amp;quot;}}}' -m cljs.main -e &amp;quot;(require '[cljs.core.async :refer [chan go]]) (go (js/console.log \&amp;quot;Foo\&amp;quot;) (js-debugger) (js/console.log \&amp;quot;Bar\&amp;quot;))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
which will generate a Js error like &amp;quot;SyntaxError: expected expression, got keyword 'debugger'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The compiled Js output will contain something like:&lt;br /&gt;
&lt;br /&gt;
{code:javascript}var inst_2199 = debugger;&lt;br /&gt;
&lt;br /&gt;
but {{debugger}} is a statement, not an expression that can be assigned.</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/598/cljs-cannot-use-js-debugger-in-go-block</guid>
<pubDate>Mon, 16 Apr 2018 15:57:10 +0000</pubDate>
</item>
<item>
<title>`go` fails to compile expressions with literal `nil` as a let value</title>
<link>https://ask.clojure.org/index.php/303/go-fails-to-compile-expressions-with-literal-nil-as-let-value</link>
<description>Minimal repro: &lt;br /&gt;
&lt;br /&gt;
clojure.core.async=&amp;gt; (fn [] (go&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [a nil&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foo (identity a)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&amp;lt;! foo))))&lt;br /&gt;
CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:1207:41) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Patch*: 0001-ASYNC-212-fix-expressions-with-nil-local.patch</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/303/go-fails-to-compile-expressions-with-literal-nil-as-let-value</guid>
<pubDate>Mon, 15 Jan 2018 14:41:35 +0000</pubDate>
</item>
<item>
<title>`a/map` close out channel immediately when any one of inputs closed</title>
<link>https://ask.clojure.org/index.php/299/map-close-out-channel-immediately-when-any-one-inputs-closed</link>
<description>&lt;p&gt;&lt;code&gt;(def c1 (chan))
(def c2 (chan))
(def out (a/map vector [c1 c2]))
(a/close! c1)
(a/&amp;lt;!! out) ;; will hangs until I put item to `c2` or close `c2`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I think the better way is close output channel immediately when any of input channels closed.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/299/map-close-out-channel-immediately-when-any-one-inputs-closed</guid>
<pubDate>Tue, 09 Jan 2018 07:24:13 +0000</pubDate>
</item>
<item>
<title>Puts committed on take! when buffer is full and buffer contains an expanding transducer</title>
<link>https://ask.clojure.org/index.php/590/puts-committed-buffer-buffer-contains-expanding-transducer</link>
<description>&lt;p&gt;This issue came up here: &lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/d/topic/clojure/w_p4f3gNo3s/discussion&quot;&gt;https://groups.google.com/d/topic/clojure/w_p4f3gNo3s/discussion&lt;/a&gt;&lt;br&gt;
Another (possibly) related previous discussion: &lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/d/topic/clojure-dev/9Ai-ZuCezOY/discussion&quot;&gt;https://groups.google.com/d/topic/clojure-dev/9Ai-ZuCezOY/discussion&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The scenario:&lt;br&gt;
1. a channel has a fixed buffer of 1 and an expanding transducer &lt;code&gt;(mapcat identity)&lt;/code&gt;&lt;br&gt;
2. a single put! is performed with a collection (C1)&lt;br&gt;
3. a blocking take! is initiated in another thread&lt;br&gt;
4. a second put! is performed with another collection&lt;/p&gt;
&lt;p&gt;I expected any put!'s to fail until all elements of collection C1 are taken from the channel.&lt;/p&gt;
&lt;p&gt;Non-blocking put!'s (via offer!) do fail until then.&lt;/p&gt;
&lt;p&gt;Blocking put!'s do block -- but only until a single take! is executed on the channel. That's surprising. Where does the put!'s value go? Everything does continue to &quot;work&quot; as expected, but the buffer acts like it has grown to size 2 (2 input collections, 1 partially output via the transducer)&lt;/p&gt;
&lt;p&gt;I believe this is resolved by checking whether the buffer is full during a take! after the call to &lt;code&gt;(impl/remove! buffer)&lt;/code&gt; but before processing any puts. See the patch for exactly what I mean. I'm not sure whether this change breaks anything as I'm not too familiar with this codebase; though tests do pass.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/590/puts-committed-buffer-buffer-contains-expanding-transducer</guid>
<pubDate>Sat, 06 Jan 2018 17:21:34 +0000</pubDate>
</item>
<item>
<title>&lt;! and &gt;! should be macros</title>
<link>https://ask.clojure.org/index.php/360/and-should-be-macros</link>
<description>&lt;p&gt;From a user perspective, &amp;lt;! and &amp;gt;! are not functions, since they can't be used as functions inside a go block; e.g. &lt;code&gt;(go (apply &amp;lt;! ...))&lt;/code&gt; is not a valid form. This is a problem, since it 1) causes confusion among users, and 2) causes bugs in other macros, e.g. CLJ-2291.&lt;/p&gt;
&lt;p&gt;Proposed solution: make &amp;lt;! and &amp;gt;! macros.&lt;/p&gt;
&lt;p&gt;Backwards compatibility: the change shoudn't introduce any breaking changes, since &amp;lt;! cannot be used as a function anyway. The change will introduce a mismatch between &amp;lt;!! and &amp;lt;!, one being a function and the other not, but that mismatch is in line with the differences in the semantics between the two.&lt;/p&gt;
&lt;p&gt;Potentially, it would also move &quot;&amp;gt;! used not in (go ...) block&quot;-type errors to compile-time, cleanly solving some issues reported earlier, e.g.: (link: &lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.clojure.org/jira/browse/ASYNC-168?focusedCommentId=42881&amp;amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-42881&quot;&gt;https://dev.clojure.org/jira/browse/ASYNC-168?focusedCommentId=42881&amp;amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-42881&lt;/a&gt; text: ASYNC-168)&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/360/and-should-be-macros</guid>
<pubDate>Wed, 13 Dec 2017 19:39:33 +0000</pubDate>
</item>
<item>
<title>alts!! completes more than one operation when reading and writing to the same channel.</title>
<link>https://ask.clojure.org/index.php/338/alts-completes-more-than-operation-reading-writing-channel</link>
<description>&lt;p&gt;The (link: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/2afc2dc5102f60713135ffca6fab993fb35809f0/src/main/clojure/clojure/core/async.clj#L277&quot;&gt;https://github.com/clojure/core.async/blob/2afc2dc5102f60713135ffca6fab993fb35809f0/src/main/clojure/clojure/core/async.clj#L277&lt;/a&gt; text: documentation) states:&lt;/p&gt;
&lt;p&gt;&quot;Completes at most one of several channel operations&quot;&lt;/p&gt;
&lt;p&gt;When running the following example, the expected outcome would be a deadlock, but the code returns either (link: 42 c) or (link: true c).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(let [c (clojure.core.async/chan)] (clojure.core.async/alts!! [c [c 42]]))&lt;/code&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/338/alts-completes-more-than-operation-reading-writing-channel</guid>
<pubDate>Wed, 15 Nov 2017 16:45:34 +0000</pubDate>
</item>
<item>
<title>Loop in go breaks type hints</title>
<link>https://ask.clojure.org/index.php/334/loop-in-go-breaks-type-hints</link>
<description>&lt;p&gt;Type hinting inside of go-loop or a go block with a loop in it loses the type hinting information. It appears that a channel must be read from in order for the data to be lost.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user=&amp;gt; (require ['clojure.core.async :as 'async])&lt;br&gt;
nil&lt;br&gt;
user=&amp;gt; (import 'java.util.Date)&lt;br&gt;
java.util.Date&lt;br&gt;
user=&amp;gt; (set! &lt;em&gt;warn-on-reflection&lt;/em&gt; true)&lt;br&gt;
true&lt;br&gt;
user=&amp;gt; (let [a [(Date.) (Date.)]
  #_=&amp;gt;       ch (async/chan)]&lt;br&gt;
  #&lt;em&gt;=&amp;gt;   (async/go-loop []&lt;br&gt;
  #&lt;/em&gt;=&amp;gt;     (when (async/&amp;lt;! ch)&lt;br&gt;
  #&lt;em&gt;=&amp;gt;       (println (.getDate ^Date (get a 0)))&lt;br&gt;
  #&lt;/em&gt;=&amp;gt;       (recur))))&lt;br&gt;
Reflection warning, /tmp/form-init7283017118477479525.clj:3:3 - reference to field getDate on java.lang.Object can't be resolved.&lt;/p&gt;
&lt;h2&gt;object[clojure.core.async.impl.channels.ManyToManyChannel 0x2572eb4e &quot;clojure.core.async.impl.channels.ManyToManyChannel@2572eb4e&quot;]&lt;/h2&gt;
&lt;p&gt;user=&amp;gt; (let [a [(Date.) (Date.)]
  #_=&amp;gt;       ch (async/chan)]&lt;br&gt;
  #&lt;em&gt;=&amp;gt;   (async/go-loop []&lt;br&gt;
  #&lt;/em&gt;=&amp;gt;     (when (async/&amp;lt;! ch)&lt;br&gt;
  #_=&amp;gt;       (println (.getDate ^Date (get a 0))))))&lt;/p&gt;
&lt;h2&gt;object[clojure.core.async.impl.channels.ManyToManyChannel 0x12e8b6a3 &quot;clojure.core.async.impl.channels.ManyToManyChannel@12e8b6a3&quot;]&lt;/h2&gt;
&lt;p&gt;user=&amp;gt; (let [a [(Date.) (Date.)]]&lt;br&gt;
  #&lt;em&gt;=&amp;gt;   (async/go-loop []                                                                                                                                    &lt;br&gt;
  #&lt;/em&gt;=&amp;gt;     (println (.getDate ^Date (get a 0)))&lt;br&gt;
  #&lt;em&gt;=&amp;gt;     (throw (Exception. &quot;repl abort&quot;))&lt;br&gt;
  #&lt;/em&gt;=&amp;gt;     (recur)))&lt;br&gt;
12&lt;/p&gt;
&lt;h2&gt;object[clojure.core.async.impl.channels.ManyToManyChannel 0x1b48111e &quot;clojure.core.async.impl.channels.ManyToManyChannel@1b48111e&quot;]&lt;/h2&gt;
&lt;p&gt;Exception in thread &quot;async-dispatch-1&quot; java.lang.Error: java.lang.Exception: repl abort&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Caused by: java.lang.Exception: repl abort&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;at user$eval1611$fn__1618$state_machine__6321__auto____1621$fn__1623$fn__1625.invoke(form-init7283017118477479525.clj:3)
at user$eval1611$fn__1618$state_machine__6321__auto____1621$fn__1623.invoke(form-init7283017118477479525.clj:2)
at user$eval1611$fn__1618$state_machine__6321__auto____1621.invoke(form-init7283017118477479525.clj:2)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:975)
at user$eval1611$fn__1618.invoke(form-init7283017118477479525.clj:2)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
... 2 more
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/334/loop-in-go-breaks-type-hints</guid>
<pubDate>Mon, 13 Nov 2017 00:57:38 +0000</pubDate>
</item>
<item>
<title>Pausing in mix is note effective</title>
<link>https://ask.clojure.org/index.php/355/pausing-in-mix-is-note-effective</link>
<description>&lt;p&gt;The following happens when using {{mix}}:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(def c1 (to-chan (range 100 105)))
(def c2 (to-chan (range 10 15)))
(def mch (chan))
(def m (mix mch))
(admix m c1)
(admix m c2)
(toggle m {c1 {:pause true}})
=&amp;gt; true
(&amp;lt;!! mch)
=&amp;gt; 100
(&amp;lt;!! mch)
=&amp;gt; 101
(&amp;lt;!! mch)
=&amp;gt; 10&lt;/code&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/355/pausing-in-mix-is-note-effective</guid>
<pubDate>Fri, 22 Sep 2017 21:24:50 +0000</pubDate>
</item>
<item>
<title>Writing on a closed channel doesn't commit the handler</title>
<link>https://ask.clojure.org/index.php/354/writing-on-a-closed-channel-doesnt-commit-the-handler</link>
<description>&lt;br /&gt;
(let [closed (doto (a/chan) a/close!)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;open (a/chan)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(a/go-loop []&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(a/alts! [open [closed true]] :priority true)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(recur)))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
throws &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Exception in thread &amp;quot;async-dispatch-1&amp;quot; java.lang.AssertionError: Assert failed: No more than 1024 pending takes are allowed on a single channel.&lt;br /&gt;
(&amp;lt; (.size takes) impl/MAX-QUEUE-SIZE)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; at clojure.core.async.impl.channels.ManyToManyChannel.take_BANG_(channels.clj:235)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; at clojure.core.async$do_alts$fn__8030.invoke(async.clj:253)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; at clojure.core.async$do_alts.invokeStatic(async.clj:245)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; at clojure.core.async$do_alts.invoke(async.clj:237)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my analysis is that when a write is attempted on a closed channel the handler should be commited, so as to allow cleanup of the handler registrations on other channels.&lt;br /&gt;
&lt;br /&gt;
See &lt;a href=&quot;https://github.com/clojure/core.async/blob/822920a45e5ea7fa28641922559fdeb888c15d05/src/main/clojure/clojure/core/async/impl/channels.clj#L74-L75&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://github.com/clojure/core.async/blob/822920a45e5ea7fa28641922559fdeb888c15d05/src/main/clojure/clojure/core/async/impl/channels.clj#L74-L75&lt;/a&gt;</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/354/writing-on-a-closed-channel-doesnt-commit-the-handler</guid>
<pubDate>Thu, 21 Sep 2017 14:12:16 +0000</pubDate>
</item>
<item>
<title>&quot;dynamic binding + parking&quot; removes top values of dynamic bindings outside</title>
<link>https://ask.clojure.org/index.php/307/dynamic-binding-parking-removes-dynamic-bindings-outside</link>
<description>&lt;p&gt;Parking inside binding block removes current values of dynamically bound vars.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(require '[clojure.core.async :as async :refer [go &amp;lt;!]])&amp;lt;/p&amp;gt;
&lt;/p&gt;&lt;p&gt;(def ^:dynamic d)&lt;/p&gt;
&lt;p&gt;(go&lt;br&gt;
  (binding [d :bound]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(println d)
(&amp;lt;! (async/timeout 10))
(println d)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here is the output:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;:bound&lt;/p&gt;
&lt;h2&gt;object[clojure.lang.Var$Unbound 0x15f8a952 Unbound: #'user/d]&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/307/dynamic-binding-parking-removes-dynamic-bindings-outside</guid>
<pubDate>Mon, 11 Sep 2017 13:57:16 +0000</pubDate>
</item>
<item>
<title>Channel returned by to-chan not immediately ready for taking?</title>
<link>https://ask.clojure.org/index.php/336/channel-returned-by-to-chan-not-immediately-ready-for-taking</link>
<description>&lt;p&gt;Not sure if this is really a bug but it stroke me as odd:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(async/poll! (async/to-chan [1 2 3])) ; =&amp;gt; nil&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Seems like the channel returned by {{to-chan}} should always be immediately ready for taking. Then again this is not mentioned in its docstring so maybe it's all fine. Just thought I'd file it in case it might hint at some deeper issue with &lt;code&gt;poll!&lt;/code&gt; or {{to-chan}}.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/336/channel-returned-by-to-chan-not-immediately-ready-for-taking</guid>
<pubDate>Fri, 11 Aug 2017 17:43:32 +0000</pubDate>
</item>
<item>
<title>(CLJS) A &quot;finally&quot; in a &quot;try&quot; in a &quot;go&quot; block is skipped in f a string is thrown.</title>
<link>https://ask.clojure.org/index.php/359/cljs-finally-in-try-in-go-block-is-skipped-in-string-is-thrown</link>
<description>&lt;p&gt;In ClojureScript a &quot;finally&quot; is ignored if a string is thrown and the enclosing &quot;try&quot; is in a &quot;go&quot; block.&lt;/p&gt;
&lt;p&gt;Example code:&lt;/p&gt;
&lt;p&gt;(ns demo&lt;br&gt;
(:require-macros&lt;br&gt;
(link: cljs.core.async.macros :refer [go)]))&lt;/p&gt;
&lt;p&gt;;; Prints: &quot;in a finally&quot;&lt;br&gt;
(go (try (throw (ex-info  &quot;THROWN&quot; nil)) (finally (println &quot;in a finally&quot;))))&lt;/p&gt;
&lt;p&gt;;; Prints: &quot;in a finally&quot;&lt;br&gt;
(go (try (throw (js/Exception.  &quot;THROWN&quot;)) (finally (println &quot;in a finally&quot;))))&lt;/p&gt;
&lt;p&gt;;; Prints: &quot;in a finally&quot;&lt;br&gt;
(go (try (throw (#js {})) (finally (println &quot;in a finally&quot;))))&lt;/p&gt;
&lt;p&gt;;; Prints: &quot;in a finally&quot;&lt;br&gt;
(try (throw &quot;THROWN&quot;) (finally (println &quot;in a finally&quot;)))&lt;/p&gt;
&lt;p&gt;;; Prints: nothing&lt;br&gt;
(go (try (throw &quot;THROWN&quot;) (finally (println &quot;in a finally&quot;))))&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/359/cljs-finally-in-try-in-go-block-is-skipped-in-string-is-thrown</guid>
<pubDate>Thu, 13 Jul 2017 11:06:19 +0000</pubDate>
</item>
<item>
<title>(CLJS) A &quot;finally&quot; including an &quot;if&quot;  breaks the result of the enclosing &quot;try&quot; if the &quot;try&quot; is in a &quot;go&quot; block</title>
<link>https://ask.clojure.org/index.php/358/cljs-finally-including-breaks-the-result-enclosing-try-block</link>
<description>&lt;p&gt;If there is a &quot;if&quot; in a &quot;finally&quot; block and the enclosing &quot;try&quot; is in a CLJS &quot;go&quot; block, then the result of the &quot;try&quot; is always nil.&lt;/p&gt;
&lt;p&gt;Example code:&lt;/p&gt;
&lt;p&gt;(ns demo&lt;br&gt;
  (:require-macros&lt;br&gt;
   (link: cljs.core.async.macros :refer [go)]))&lt;/p&gt;
&lt;p&gt;;; Prints: &quot;in a try&quot;&lt;br&gt;
(println (try &quot;in a try&quot; (finally (if true nil ))))&lt;/p&gt;
&lt;p&gt;;; Prints: &quot;in a try&quot;&lt;br&gt;
(go (println (try &quot;in a try&quot; (finally nil))))&lt;/p&gt;
&lt;p&gt;;; Prints: nil&lt;br&gt;
(go (println (try &quot;in a try&quot; (finally (if true nil )))))&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/358/cljs-finally-including-breaks-the-result-enclosing-try-block</guid>
<pubDate>Thu, 13 Jul 2017 10:59:31 +0000</pubDate>
</item>
</channel>
</rss>