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
8
votes
1 answer

Is Clojure's core.async similar to Jane Street's OCaml Core Async?

In this blog post the author writes: However, Grenchman is built on the Core and Async libraries from Jane Street, one of the largest industrial users of OCaml. Async allows for monadic faux-concurrency that avoids a lot of the callback headaches…
hawkeye
  • 31,052
  • 27
  • 133
  • 271
7
votes
2 answers

Handling errors with clojure core.async pipeline

I am trying to understand what's the correct way to handle errors using core.async/pipeline, my pipeline is the following: input --> xf-run-computation --> first-out first-out --> xf-run-computation --> last-out Where xf-run-computation will do…
Michel Uncini
  • 305
  • 1
  • 13
7
votes
1 answer

How to properly batch messages with core.async?

I would like to batch messages on a core.async chan by count and timeout, (i.e. 10ms or 10 messages, whichever comes first). Tim Baldridge has a video on batching, but it uses deprecated functions in core.async and does not use transducers. I'm…
jwhitlark
  • 475
  • 3
  • 15
7
votes
2 answers

Waiting for n channels with core.async

In the same way alt! waits for one of n channels to get a value, I'm looking for the idiomatic way to wait for all n channels to get a value. I need this because I "spawn" n go blocks to work on async tasks, and I want to know when they are all…
Blacksad
  • 13,286
  • 14
  • 63
  • 78
7
votes
3 answers

How to determine when a core.async channel is closed from the writer's side?

I have a process that is basically part of a long polling implementation. In a nutshell, the client makes a request to the server, which then creates a channel and returns it to that client. The channel will contain the information that client asked…
user1246334
  • 101
  • 1
  • 6
7
votes
3 answers

Clojure core.async, CPU hangs after timeout. Anyway to properly kill macro thread produced by (go..) block?

Based on core.async walk through example, I created below similar code to handle some CPU intensive jobs using multiple channels with a timeout of 10 seconds. However after the main thread returns, the CPU usage remains around 700% (8 CPUs…
Kevin Zhu
  • 2,429
  • 24
  • 22
6
votes
4 answers

Throttle Functions with core.async

The number of possible executions of a function should be throttled. So after calling a function, any repeated call should be ignored within a time period. If there where calls in the meantime, the last one should be executed after the time…
Anton Harald
  • 5,402
  • 2
  • 17
  • 45
6
votes
1 answer

Clojure core.async put! versus go block

I've read this great article about core.async here: http://www.core-async.info/reference/primitives I'm struggling to understand the internal mechanic of put! and go. I understand that: put! is asynchronous and can accept a callback. That works…
Nicolas Dao
  • 652
  • 7
  • 16
6
votes
1 answer

Why is the threadpool for core.async in clojure created with fixed thread pool of # of cores times 2 plus 42?

The threadpool implementation in core.async clojure library uses a FixedThreadPoolExecutor of size = # of cores * 2 + 42. (defonce the-executor (Executors/newFixedThreadPool (-> (Runtime/getRuntime) (.availableProcessors) (*…
wildnux
  • 378
  • 5
  • 21
6
votes
1 answer

core.async pub/sub behaves odd in Om (clojurescript)

Why is the counter in the child component updating fine when I comment (om/update-state! owner :clicked not) and not when I uncomment it in the parent component in the code below? The counter is updated by clicking the button. What I'm trying to…
Michiel Borkent
  • 31,814
  • 15
  • 78
  • 134
6
votes
5 answers

clojurescript could not locate cljs.core.async.macros

I have the following code in the file client.cljs : (ns onn.client (:require [enfocus.core :as ef] [enfocus.effects :as effects] [enfocus.events :as events] [clojure.browser.repl :as repl] [goog.net.XhrIo…
vidi
  • 1,722
  • 13
  • 28
6
votes
2 answers

Clojure core.async, any way to control number of threads in that (go...) thread pool?

By default (go..) will use twice the number of cores + 42 threads for the thread pool. Is there any way I can set the number of threads, or number of CPUs that the code can use, through setting an environment variable or sth? On linux machine I can…
Kevin Zhu
  • 2,429
  • 24
  • 22
5
votes
2 answers

Why does `core.async/pipeline` return a channel?

I just noticed that the pipeline family returns a channel which seemingly operates completely independently of the purpose of the pipeline and it's related channels. Notice in the following example you can >! / / b> separately,…
Josh.F
  • 3,077
  • 2
  • 18
  • 33
5
votes
1 answer

How to implement the Skynet 1m microbenchmark with core.async?

In order to try to understand core.async, I unsuccesfully tried to implement the "Skynet 1 million microbenchmark", which is: Creates an actor (goroutine, whatever), which spawns 10 new actors, each of them spawns 10 more actors, etc. until one…
Cedric Martin
  • 5,798
  • 4
  • 26
  • 61
5
votes
3 answers

Clojure core.async for data computation

I've started using the clojure core.async library. I found the concepts of CSP, channels, go blocks really easy to use. However, I'm not sure if I'm using them right. I've got the following code - (def x-ch (chan)) (def y-ch (chan)) (def w1-ch…
Lordking
  • 1,413
  • 1
  • 12
  • 31
1 2
3
15 16