Skip to content

Instantly share code, notes, and snippets.

@marcoy
Last active November 12, 2020 14:14
Show Gist options
  • Select an option

  • Save marcoy/983b8b346ed9ecc4a55a to your computer and use it in GitHub Desktop.

Select an option

Save marcoy/983b8b346ed9ecc4a55a to your computer and use it in GitHub Desktop.

Revisions

  1. marcoy renamed this gist Jun 8, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. marcoy renamed this gist Jun 8, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. marcoy revised this gist Jun 8, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ;; 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]
  4. marcoy created this gist Jun 8, 2014.
    16 changes: 16 additions & 0 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    (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]>