Am Mo., 7. Jan. 2019 um 11:20 Uhr schrieb Oleksandr Shulgin <
oleksandr.shul...@zalando.de>:

>
> Is it intended that calling `await` on an agent triggers the watch
> functions?
>
> From the implementation side I can see why this is the case, but cannot
> find if this is documented as intended behavior:
> https://github.com/clojure/clojure/blob/ee3553362de9bc3bfd18d4b0b3381e3483c2a34c/src/clj/clojure/core.clj#L3274
>
> For one, it doesn't seem like waiting for an agent involves change in it
> state in any way.
>
>
I don't think that this behavior is explicitly intended, but I don't think
that it's faulty either.

I'd argue that any watcher function should be robust towards being
triggered without changes:

1) (send a identity) should always be a no-op without any hidden
implications. That's important, so that any agent function will be able to
decide to do nothing.
2) Trying to filter spurious notifications before the actual decider is
generally a fools errand in distributed systems. Compare to how, in Java,
you always need to call Object.wait() in a loop with its condition:
https://docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html

Admittedly, the second part of my argument doesn't directly apply, since
the invokation-order and values for agent watchers are well-defined, but
still, assuming that a condition is met, just because a watcher is
triggered, will lead to a brittle system.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to