Questions tagged [core.async]

A clojure/clojurescript library for asynchronous programming.

core.async is a clojure/clojurescript library to allow a model of asynchronous programming similar to that of the Go language.

229 questions
10
votes
3 answers

Server push of data from Clojure to ClojureScript

I'm writing an application server in Clojure that will use ClojureScript on the client. I'd like to find an efficient, idiomatic way to push data from the server to the client as realtime events, ideally using a some combination…
mikera
  • 101,777
  • 23
  • 241
  • 402
10
votes
2 answers

core.async and 10,000 processes for animation - what is the actual benefit in this scenario?

As we know - core.async uses CSP and is similar to goroutines from go-lang. Now for a scenario like select and alt this makes a lot of sense. David Nolen has done an amazing demo here showing core.async in Clojure at work in animation in…
hawkeye
  • 31,052
  • 27
  • 133
  • 271
10
votes
3 answers

Gracefully exit a Clojure core.async go loop on kill

I have a top-level core.async go loop. I want it to run indefinitely, at least until I signal it to stop with CTRL-C or kill or similar. I'm currently using java.lang.Runtime/addShutdownHook like this: (ns async-demo.core (:require…
David J.
  • 28,507
  • 20
  • 108
  • 162
9
votes
1 answer

Where is the memory leak when mapcat breaks backpressure in core.async?

I wrote some core.async code in Clojure and when I ran it it consumed all available memory and failed with an error. It appears that using mapcat in a core.async pipeline breaks back pressure. (Which is unfortunate for reasons beyond the scope of…
9
votes
3 answers

How to best shut down a clojure core.async pipeline of processes

I have a clojure processing app that is a pipeline of channels. Each processing step does its computations asynchronously (ie. makes a http request using http-kit or something), and puts it result on the output channel. This way the next step can…
Marten Sytema
  • 1,826
  • 2
  • 20
  • 28
9
votes
3 answers

How to stop go block in ClojureScript / core.async?

Is there an elegant way to stop a running go block? (without introducing a flag and polluting the code with checks/branches) (ns example (:require-macros [cljs.core.async.macros :refer [go]]) (:require [cljs.core.async :refer [
oshyshko
  • 2,009
  • 2
  • 20
  • 31
9
votes
1 answer

Clojure core.async, channel vs port

In Clojure core.async, are channels and ports the same thing? If not what's the difference? In watching the video Timothy Baldridge - Core.Async, he creates a channel (def c (chan)) Then later (
Steve Kuo
  • 58,491
  • 75
  • 189
  • 247
9
votes
2 answers

Clojure - Why does execution hang when doing blocking insert into channel? (core.async)

Consider the following snippet: (let [chs (repeatedly 10 chan)] (doseq [c chs] (>!! c "hello")) (doseq [c chs] (println (! c "hello")) instead, it works just fine.
Mark
  • 33,211
  • 11
  • 39
  • 45
9
votes
1 answer

Is it sane to use core.async channels to consume http-kit's post results in clojure?

I am new to clojure and am writing a library that sends post results to a server for a response. I consume the response by placing it onto a core.async channel. Is this sane or is there a better way? Here is a high level overview of what I am…
gilmaso
  • 209
  • 4
  • 8
8
votes
3 answers

How does one clearly structure dependencies between core.async channels?

Let's say I have a corpus of computations that I want to run asynchronously using core.async, but unfortunately a few of the functions depend on the output of other functions. How do I go about structuring this cleanly in my code, while also getting…
Ben
  • 554
  • 4
  • 11
8
votes
1 answer

How to create a channel from another with transducers?

I want to create a channel of clojure.core.async from another one that just filters specific messages. Therefore I found a function called filter<. => (def c1 (chan)) => (def c2 (filter< even? c1)) => (put! c1 1) => (put! c1 2) => (
sschmeck
  • 5,803
  • 2
  • 30
  • 53
8
votes
2 answers

go block vs thread in core.async

From http://martintrojer.github.io/clojure/2013/07/07/coreasync-and-blocking-io/ : To get a bit more concrete let's see what happens when we try to issue some HTTP GET request using core.async. Let's start with the naive solution, using…
qed
  • 19,750
  • 16
  • 99
  • 168
8
votes
3 answers

How do clojure core.async channels get cleaned up?

I'm looking at Clojure core.async for the first time, and was going through this excellent presentation by Rich Hickey: http://www.infoq.com/presentations/clojure-core-async I had a question about the example he shows at the end of his…
Ord
  • 5,113
  • 4
  • 25
  • 42
8
votes
1 answer

Could core.async have implemented its functions in terms of sequences?

Rich Hickey's Strange Loop transducers presentation tells us that there are two implementations of map in Clojure 1.6, one for sequences in clojure.core and one for channels in core.async. Now we know that in 1.7 we have transducers, for which a…
hawkeye
  • 31,052
  • 27
  • 133
  • 271
8
votes
2 answers

Can we describe Clojure's core.async as 'continuation passing style'?

In Clojure's core.async library we see a macro that creates a state machine that wraps around go blocks to create channels that handle blocking IO. This appears to be modelling on C#'s async and on Go-lang's goroutines. In The Seasoned Schemer -…
hawkeye
  • 31,052
  • 27
  • 133
  • 271
1
2
3
15 16