Verified Commit 3bc6beec authored by Camil Staps's avatar Camil Staps 🚀

Use a CAF for the tcpRx share

parent 5d289897
...@@ -96,6 +96,9 @@ tcpShare =: sdsFocus "tcpShare" (memoryStore "Electron" (Just ...@@ -96,6 +96,9 @@ tcpShare =: sdsFocus "tcpShare" (memoryStore "Electron" (Just
, tcpTx = 'Data.Map'.newMap , tcpTx = 'Data.Map'.newMap
})) }))
tcpRx :: SimpleSDSLens (Map ElectronProcess [TCPMsg])
tcpRx =: mapReadWrite (\s -> s.tcpRx, \rx s -> Just {s & tcpRx=rx}) Nothing tcpShare
tcpQueueEmpty :: SimpleSDSLens Bool tcpQueueEmpty :: SimpleSDSLens Bool
tcpQueueEmpty =: mapReadWrite tcpQueueEmpty =: mapReadWrite
( \{tcpTx} -> all isEmpty ('Data.Map'.elems tcpTx) ( \{tcpTx} -> all isEmpty ('Data.Map'.elems tcpTx)
...@@ -199,8 +202,6 @@ where ...@@ -199,8 +202,6 @@ where
sequence [handle processId msg \\ (processId,msgs) <- 'Data.Map'.toList rx, msg <- msgs] ||- sequence [handle processId msg \\ (processId,msgs) <- 'Data.Map'.toList rx, msg <- msgs] ||-
loop pie loop pie
where where
tcpRx = mapReadWrite (\s -> s.tcpRx, \rx s -> Just {s & tcpRx=rx}) Nothing tcpShare
handle :: !ElectronProcess !TCPMsg -> Task () handle :: !ElectronProcess !TCPMsg -> Task ()
handle processId msg = handle processId msg =
get (tcpConnection processId) >>- \mbConnection -> get (tcpConnection processId) >>- \mbConnection ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment