Fork me on GitHub
#clojure-dev
<
2017-06-20
>
leonoel13:06:42

agents seem to mess up dynamic vars when run on a synchronous executor (send-via (reify Executor (execute [_ r] (.run ^Runnable r))) (agent nil) identity)

leonoel13:06:05

is it bug or feature ?

bronsa13:06:25

it seems intentional from the source (it uses binding-conveyor-fn which only works on separate threads)

bronsa13:06:48

and with agents being asynchronous, trying to use them synchronously doesn't seem to be a good idea

leonoel13:06:02

the idea doesn't sound that bad to me, sometimes you know the transformation is lightweight so you may want to avoid the price of a thread switch

leonoel13:06:04

after all, synchronous is just a special case of asynchronous

leonoel13:06:49

but maybe agents were not designed for that case