some-operation
私は(例のように)一連の機能を持っていsend
ますsend-off
。
(defn some-operation [agent-state]
(dosync
(let [updated (foo agent-state)] ;; derive new state from old one
(alter bar whatev updated) ;; reflect the new state in the world
(send *agent* some-operation) ;; "recur"
updated) ;; value for recur
))
(send (agent {}) some-operation)
このアプローチは、アプリを開発しているときにうまくいきました。しかし、コードベースにいくつかの変更を加えた後、エージェントはしばらくすると実行を停止します (「しばらく」は数秒で、数千の「再帰的」呼び出しです)。
それらの状態はドメイン内で有効であり、エージェント自体は有効ではなく、ブロックFAILED
でライブロックしていないことは確かです(競合を測定できます)。dosync
私の疑いは、何らかの理由で、JVM/OS が基になるエグゼキューター スレッドの実行を妨げていることです。しかし、この仮定が正しいかどうかを確認する方法がわかりません。
一般的に、送信エージェントが保留中の「送信」を実行できない理由として考えられるものは何ですか? 何を検査/測定できますか?
更新- デバッグ用に次の変更を行うと...
(defn some-operation [agent-state]
(let [f (future
(dosync
...) ;; the whole operation, as per the previous example
)]
(Thread/sleep 1000) ;; give the operation some time
(if (realized? f)
@f
;; not realized: we deem the operation as blocking indefinetely
(do
(println :failed)
(send *agent* some-operation)
agent-state))))
...エージェントはまだスタックしており、印刷さえしません:failed
。