(ns scratch (:require [clojure.core.async :as a] [taoensso.timbre :as timbre])) (def core-async-agent-state (atom 0)) (def core-async-agent-ch (a/chan 1)) (def p2 (a/pipeline-blocking 1 ;To (black hole) (a/chan (a/sliding-buffer 1) (map (fn [task-finished] (timbre/spy task-finished)))) ;Xf (map (fn [task] (timbre/spy task) ;TODO do something... (swap! core-async-agent-state (fn [x] (inc x))) task)) ;from core-async-agent-ch)) (defn run-go [wait-ms] (a/go (let [task-status (a/alts! [[core-async-agent-ch :a-task] (a/timeout wait-ms)]) submit-ok? (first task-status)] (timbre/spy submit-ok?) #_(timbre/spy task-status)))) (comment (let [wait-ms 20] (repeatedly 500 #(run-go wait-ms)))) (comment ;check state (do @core-async-agent-state))