Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Created June 30, 2022 17:33
Show Gist options
  • Save dustingetz/8b099c2222a4560eb8965e88747e12fa to your computer and use it in GitHub Desktop.
Save dustingetz/8b099c2222a4560eb8965e88747e12fa to your computer and use it in GitHub Desktop.
(ns wip.missionary-clock
(:require [missionary.core :as m]
[hyperfiddle.rcf :refer [tests ! % with]]))
(hyperfiddle.rcf/enable!)
(defn clock []
(->> (m/ap (loop [] (m/amb (m/? (m/sleep 1 1)) (recur))))
(m/reductions + 0) ; logical clock
#_(m/reductions {} ::tick) ; physical clock
#_(m/relieve {}) ; heater, running clock at max speed, no laziness
))
(tests
(def >clock (clock))
(def !it (>clock (fn [] (! ::notify))
(fn [] (! ::terminate))))
% := ::notify
@!it := 0
% := ::notify
@!it := 1
% := ::notify
(!it))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment