Alf Kristian Støyle
2017-08-27 06:44:24 UTC
Hi! I couldn't find a specific manifold mailing list, using aleph, hope
that's ok.
I am probably doing something incorrectly, but I am having a hard time
seeing what. And if not, there may be an issue with alt.
I am making a process which will run periodically, but it should also be
possible to kill it. This is the code:
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt kill-d (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
When running the alt does not trigger on the timeout.
(def kill (d/deferred))
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << ⊠>>
;; Witing a bit...
(d/success! kill 1)
"Got a result" 1
"Got a kill message for token, not recurring"
Modifying the code, removing the kill-d from the alt, now it works, except
there is no way of killing it;
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
(def kill (d/deferred)) ; Not really necessary...
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << ⊠>>
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
Anyone have a clue on what's going on here? I've experienced a bit with alt
in other contexts, and it seem to be working just fine. So I am a bit
baffled...
Cheers,
Alf
that's ok.
I am probably doing something incorrectly, but I am having a hard time
seeing what. And if not, there may be an issue with alt.
I am making a process which will run periodically, but it should also be
possible to kill it. This is the code:
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt kill-d (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
When running the alt does not trigger on the timeout.
(def kill (d/deferred))
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << ⊠>>
;; Witing a bit...
(d/success! kill 1)
"Got a result" 1
"Got a kill message for token, not recurring"
Modifying the code, removing the kill-d from the alt, now it works, except
there is no way of killing it;
(defn foo [kill-d]
(d/loop []
(prn "Setting up with timeout" 1000)
(d/let-flow [res (d/alt (d/timeout! (d/deferred) 1000 :ok))]
(prn "Got a result" res)
(if (= res :ok)
(d/recur)
(prn "Got a kill message for token, not recurring")))))
(def kill (d/deferred)) ; Not really necessary...
=> #'user/kill
(foo kill)
"Setting up with timeout" 1000
=> << ⊠>>
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
"Got a result" :ok
"Setting up with timeout" 1000
Anyone have a clue on what's going on here? I've experienced a bit with alt
in other contexts, and it seem to be working just fine. So I am a bit
baffled...
Cheers,
Alf
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.