Skip to content

Instantly share code, notes, and snippets.

@kamisori
Created July 15, 2020 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamisori/7b299c559e14a19332759cfc640c5de3 to your computer and use it in GitHub Desktop.
Save kamisori/7b299c559e14a19332759cfc640c5de3 to your computer and use it in GitHub Desktop.
(defn make-repl-worksnt
[getline-thread]
(defn get-chunk [line-buffer parser]
(let [msg ["#" line-buffer]]
(try (do
(thread/send getline-thread msg))
([_] nil))))
(while true (->
(repl get-chunk)
coro
resume)))
(defn make-repl-works
[getline-thread]
(defn get-chunk [line-buffer parser]
(let [msg ["#" line-buffer]]
(try (do
(thread/send getline-thread msg))
([_] nil))))
(while true (->
(run-context {:chunks get-chunk})
coro
resume)))
(defn gament
[getline-thread]
(def repl-fiber (make-repl-worksnt getline-thread))
(while true
(try
(let [msg (thread/receive 0)]
(resume repl-fiber msg))
([_] nil))))
(defn game
[getline-thread]
(def repl-fiber (make-repl-works getline-thread))
(while true
(try
(let [msg (thread/receive 0)]
(resume repl-fiber msg))
([_] nil))))
(defn main
[& args]
(var game-thread nil)
(try
(set game-thread (thread/new gament 32))
([err] (do (print "couldnt: " err)
(set game-thread (thread/new game 32)))))
(while true
(def [line-prompt line-buffer]
(thread/receive math/inf))
(try (do
(thread/send game-thread
(getline line-prompt line-buffer)))
([_] nil))))
(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment