This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-03
Channels
- # bangalore-clj (2)
- # beginners (29)
- # boot (52)
- # cider (4)
- # clara (3)
- # cljs-dev (34)
- # cljsjs (7)
- # cljsrn (3)
- # clojure (71)
- # clojure-austin (1)
- # clojure-dev (5)
- # clojure-france (20)
- # clojure-russia (51)
- # clojure-spec (9)
- # clojure-uk (20)
- # clojurescript (131)
- # core-async (56)
- # core-logic (6)
- # cursive (50)
- # datascript (19)
- # datomic (16)
- # dirac (118)
- # emacs (100)
- # events (4)
- # hoplon (14)
- # incanter (1)
- # jobs (7)
- # jobs-discuss (96)
- # jobs-rus (21)
- # lein-figwheel (5)
- # leiningen (21)
- # off-topic (11)
- # om (45)
- # onyx (42)
- # pamela (1)
- # pedestal (22)
- # portland-or (3)
- # re-frame (8)
- # reagent (5)
- # ring (9)
- # robots (1)
- # spacemacs (14)
- # specter (28)
- # sql (2)
- # untangled (165)
what's strange is that it works about 1/2 of the time
Thanks for taking a look, @tbaldridge I get very inconsistent results. Like, just now:
:b read true
:b read true
hu?:b read :to-write
:a read :to-write
or any combination. But I never get a wrote something
in the log.That true
looks like it should never end up there ...
yeah, I'm really sure there's a bug here somewhere
what's really odd is that it happens with thread and alt!! as well
no clue why
Also happens when giving c
a buffer
@tbaldridge maybe there's a bug in do-alt
then?
yeah, I think the issue is related to this: "Each option may appear at most once. The choice and parking characteristics are those of alts!"
notice how nothing ever writes. This is because we're using the same channel twice, and I think the macro is doing some sort of indexing or grouping based on the channel
and the code is being mixed up with a different op
mhh I read that "each option may appear at most once" as (alt! c 43 c 42)
not being allowed, not not allowing either a take or a put to the same channel
same here, but the behavior fits
watch what happens if you increase the "dotimes [x 2]" to 4 😉
in one of my tests it printed 4 log messages
Each option may appear at most once.
is only stated in regards to alt!
. I guess I could try alts!
then, even though that wouldn't look as nice.
But I do need to say this...this is some wacky code. Writing and reading to the same channel from the same thread isn't a pattern that happens in production code.
I was trying to port the go-lang chatroulette example to Clojure: https://engineering.tumblr.com/post/23049359840/talk-by-andrew-gerrand-go-code-that-grows-with (about minute 19 in the video)
heh, I just realized something....I haven't a clue how this works with the implementation of channels....
I think it might be at the channel level
So here's how a channel works: If you put, the op locks the put handler and the channel. Then it looks for a take, if it finds a take it locks the take handler, then it commits the put and the take, and dispatches the values through the put and take handlers.
In an alt! all the branches share the same handler. So in that case the put and the take hander are the same handler. But all the semantics of the handler are commit/deliver once.
Well you stumped me and bronsa, so (thumbsup) for that one 🙂
It'll probably be awhile before I hear back from Rich, and I'm 90% sure the answer is "don't do that", but I'm interested in hearing if he agrees with my theory
I must admit that it looked like a clever bit of code in the go-lang example. Now I have to come up with a different way to do the connection pairing 🙂
Yeah go seems fond of that sort of stuff for some reason
Apparently writing to a channel then reading from that same channel is a pattern in go-lang
Nice detective work!