Comments (3)
Since is not a private code I will submit it here to fast testing with the actual environment, it's a tutorial code.
(ns hospital.aula6
(:use [clojure pprint])
(:require
[hospital.model :as h.model]))
(defn cabe-na-fila?
[fila]
(-> fila
count
(< 5)))
(defn chega-em
[fila pessoa]
(if (cabe-na-fila? fila)
(conj fila pessoa)
(throw (ex-info "Fila já está cheia" {:tentando-adiconar pessoa}))))
(defn chega-em! [hospital pessoa]
(let [fila (get hospital :espera)]
(alter fila chega-em pessoa)))
(defn simula-um-dia
[]
(let [hospital {:espera (ref h.model/empty-queue)
:laboratorio1 (ref h.model/empty-queue)
:laboratorio2 (ref h.model/empty-queue)
:laboratorio3 (ref h.model/empty-queue)}]
(dosync
(chega-em! hospital "guilherme")
(chega-em! hospital "ana")
(chega-em! hospital "paulo")
(chega-em! hospital "paloma")
(chega-em! hospital "maria")
(chega-em! hospital "david"))
(pprint hospital)))
(simula-um-dia)
(defn async-chega-em! [hospital pessoa]
(future
(Thread/sleep (rand 5000))
(dosync
(pprint "Tentando adicionar pessoa" pessoa)
(chega-em! hospital pessoa))))
(defn simula-um-dia-async
[]
(let [hospital {:espera (ref h.model/empty-queue)
:laboratorio1 (ref h.model/empty-queue)
:laboratorio2 (ref h.model/empty-queue)
:laboratorio3 (ref h.model/empty-queue)}]
(async-chega-em! hospital 15)
(pprint hospital)))
(simula-um-dia-async)
(def empty-queue clojure.lang.PersistentQueue/EMPTY)
from conjure.
So you are expecting to see "Tentando adicionar pessoa" in the log and you are not? Do you see the output in you Clojure nREPL window instead? Because you're print
is in a different thread to the nREPL thread it means Conjure doesn't get told about the output, so in that case it normally goes to the original nREPL you are connected to.
Running :ConjureOutSubscribe
inside your editor may fix that problem and redirect ALL console output into Conjure.
If you are expecting to see values in :laboratorio1
etc though, you will not when they're pprint
-ed at the end of simula-um-dia-async
. When you call pprint
the code inside async-chega-em!
has not run yet. So you will need to store the references to the queues or the hospital
map somewhere and pprint
it later when the future has completed.
That part is just how Clojure (and all async programming) works and isn't something I can change I'm afraid. So! If your question is about the println
not showing up, I hope the command I mentioned helps, if it's about the async code not running in time, I'm afraid that's just a normal programming thing and you'll need to make your code check periodically or wait (using https://clojuredocs.org/clojure.core/deref etc) until the async code is complete before printing it.
I hope this helps!
from conjure.
I'm trying to see the "Tentando adicionar pessoa".
I did try to use the command you mentioned, nothing different happened, the output still get's "ignored" like you said it's running in another thread.
Another thing is, looking at the nREPL started by :Lein I cannot see there too, even after waiting some time, it's not a game ending behavior but in IntelliJ if you wait for some time the output gets there, so I think it should be doable.
from conjure.
Related Issues (20)
- stdio repl handling of both stderr and stdout for a form can be a problem sometimes HOT 1
- <localleader>ee, <localleader>E evaluate the whole file HOT 9
- Problems with evaluation: wrong returns HOT 3
- Guile over nREPL, guile-ares-rs integration HOT 4
- Clojure Debugger: Evaluation failing on debug reader tags HOT 4
- Local leader key not active when open scm files HOT 7
- Common-Lisp: Only first expression is evaluated using ConjureEvalBuf HOT 19
- Feature request: Re-run last test HOT 2
- Disable ConjureOmnifunc for Janet? HOT 4
- Common Lisp/ros/swank not behaving as expected HOT 15
- No syntax highlighting in log buffer when opening file using telescope. HOT 7
- HUD not popping up when using AstroVim HOT 3
- Adapt `IRust` support HOT 5
- Hy client not showing output HOT 5
- Disable LSP and Treesitter for the log buffer by default HOT 9
- Add highlighting to indicate which forms have not been changed since their last evaluation HOT 1
- Support clj-reload as well as tools.namespace reload since it's now built into nREPL
- Support lazy loading natively
- Hard resetting the log results in an error (may only be on my machine)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conjure.