Created
July 31, 2019 21:22
-
-
Save timsgardner/bbf4ed556344b8d996f5a040dfba35d1 to your computer and use it in GitHub Desktop.
problem with multithreaded breakpoints in cider
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
(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