This file contains 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
(import (clojure.asm Type ClassWriter Opcodes) | |
(clojure.asm.commons Method GeneratorAdapter) | |
(clojure.lang DynamicClassLoader Compiler$HostExpr)) | |
(require '[clojure.string :as s]) | |
(defn- struct-bytecode [cname slots] | |
(let [objtype (Type/getType ^Class Object) | |
cv (new ClassWriter (. ClassWriter COMPUTE_MAXS))] | |
(. cv (visit (. Opcodes V1_5) (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_FINAL)) |
This file contains 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
{:paths ["."] | |
:deps {missionary {:mvn/version "a.3"}}} |
This file contains 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
{:paths ["."] | |
:deps {injure {:mvn/version "1"}}} |
This file contains 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 goto) | |
(defmacro tagbody [& forms] | |
(let [start (gensym)] | |
(loop [binds [] | |
point start | |
forms forms] | |
(let [[body [jump & forms]] (split-with (complement symbol?) forms) | |
binds (conj binds `(~point [] ~@body ~jump))] | |
(if jump |
This file contains 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
;; missionary implementation of SICP's [amb](http://sarabander.github.io/sicp/html/4_002e3.xhtml#g_t4_002e3) | |
(ns amb | |
(:refer-clojure :exclude [require eval]) | |
(:require [missionary.core :as m])) | |
(deftype FlowIterator [^:unsynchronized-mutable iterator | |
^:unsynchronized-mutable pending?] | |
clojure.lang.IFn | |
(invoke [this] |
This file contains 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 ^{:doc " | |
Performance measurements for various generator implementations, cloroutine v10 https://github.com/leonoel/cloroutine | |
Based on https://clojureverse.org/t/how-to-transform-nested-map-into-flat-sequence-of-path-value-pairs/8801/22 | |
"} cloroutine-perf | |
(:require [cloroutine.core :refer [cr]])) | |
(def ^:dynamic *tail*) | |
(defn gen-seq-dv [gen] | |
(lazy-seq (binding [*tail* (gen-seq-dv gen)] (gen)))) |
This file contains 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 asyncawait | |
(:refer-clojure :exclude [await]) | |
(:require [cloroutine.core :refer [cr]])) | |
(defmacro async [& body] | |
`(js/Promise. (fn [s# f#] | |
(spawn (cr {await thunk} | |
(try (s# (do ~@body)) | |
(catch :default e# (f# e#)))))))) |
This file contains 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
;; Experiment - parallel processing using missionary primitives. | |
;; Inspired by Rx's parallel 'rails' : | |
;; http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/parallel/ParallelFlowable.html | |
;; https://dzone.com/articles/rxjava-idiomatic-concurrency-flatmap-vs-parallel | |
(ns parallel-processing | |
(:require [missionary.core :as m])) | |
(defn map-task [f >x] | |
(m/ap (m/? (f (m/?> >x))))) |
This file contains 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
;; missionary solution to petrol pump example by Stephen Blackheath and Anthony Jones, ISBN 978-1633430105 | |
;; huanhulan's demo : [live](https://huanhulan.github.io/petrol_pump), [code](https://github.com/huanhulan/petrol_pump) | |
(ns pump | |
(:refer-clojure :exclude [first]) | |
(:require [missionary.core :as m]) | |
(:import missionary.Cancelled)) | |
(defn rising | |
"A transducer that outputs `nil` when the input switches from logical false to logical true." |
This file contains 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 complex-business-process-example-missionary | |
"A stupid example of a more complex business process to implement as a flowchart." | |
(:require [missionary.core :as m]) | |
(:import missionary.Cancelled)) | |
;;;; Config | |
(def config | |
"When set to :test will trigger the not-boosted branch which won't write to db. | |
When set to :prod will trigger the boosted branch which will try to write to the db." |
OlderNewer