Skip to content

Instantly share code, notes, and snippets.

@timsgardner
Created July 31, 2019 21:22
Show Gist options
  • Save timsgardner/bbf4ed556344b8d996f5a040dfba35d1 to your computer and use it in GitHub Desktop.
Save timsgardner/bbf4ed556344b8d996f5a040dfba35d1 to your computer and use it in GitHub Desktop.
problem with multithreaded breakpoints in cider
(ns cider-experiment.core)
(def thread-log (atom []))
(defn log-thread [msg]
(swap! thread-log conj {:thread (Thread/currentThread)
:msg msg}))
;; instrument this function:
(defn f1 [x]
(do
(log-thread {:x x})
(Thread/sleep 100)
{:this-is-x x}))
(def the-results
[(future (f1 :a))
(future (f1 :b))])
;; then later:
;; (pprint @thread-log)
;; without instrumentation on f1:
;; [{:thread
;; #object[java.lang.Thread 0xe60ee4c "Thread[clojure-agent-send-off-pool-21,5,main]"],
;; :msg {:x :a}}
;; {:thread
;; #object[java.lang.Thread 0x2bb1fa6 "Thread[clojure-agent-send-off-pool-22,5,main]"],
;; :msg {:x :b}}]
;; with instrumentation on f1:
;; [{:thread
;; #object[java.lang.Thread 0x3d3bd430 "Thread[clojure-agent-send-off-pool-25,5,main]"],
;; :msg {:x :b}}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment