Last active
November 12, 2020 14:14
-
-
Save marcoy/983b8b346ed9ecc4a55a to your computer and use it in GitHub Desktop.
Change core.async threadpool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; http://stackoverflow.com/questions/18779296/clojure-core-async-any-way-to-control-number-of-threads-in-that-go-thread | |
(ns sandbox | |
(:require [clojure.core.async.impl.concurrent :as conc] | |
[clojure.core.async.impl.exec.threadpool :as tp] | |
[clojure.core.async :as async])) | |
(defonce my-executor | |
(java.util.concurrent.Executors/newFixedThreadPool | |
1 | |
(conc/counted-thread-factory "my-async-dispatch-%d" true))) | |
(alter-var-root #'clojure.core.async.impl.dispatch/executor | |
(constantly (delay (tp/thread-pool-executor my-executor)))) | |
(async/go | |
(println | |
(Thread/currentThread))) ;=> #<Thread Thread[my-async-dispatch-1,5,main]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment