@@ -144,10 +144,9 @@ setDebugSessionId session = modify' $ \s -> s { sessionId = Just session }
144144registerNewDebugSession
145145 :: SessionId
146146 -> app
147- -> IO ()
148- -- ^ Action to run debugger (operates in a forked thread that gets killed when disconnect is set)
149- -> ((Adaptor app () -> IO () ) -> IO () )
150- -- ^ Long running operation, meant to be used as a sink for
147+ -> [((Adaptor app () -> IO () ) -> IO () )]
148+ -- ^ Actions to run debugger (operates in a forked thread that gets killed when disconnect is set)
149+ -- Long running operation, meant to be used as a sink for
151150 -- the debugger to emit events and for the adaptor to forward to the editor
152151 -- This function should be in a 'forever' loop waiting on the read end of
153152 -- a debugger channel.
@@ -157,19 +156,18 @@ registerNewDebugSession
157156 -- used when sending events to the editor from the debugger (or from any forked thread).
158157 --
159158 -- >
160- -- > registerNewDebugSession sessionId appState loadDebugger $ \withAdaptor ->
159+ -- > registerNewDebugSession sessionId appState $ loadDebugger : [ \withAdaptor ->
161160 -- > forever $ getDebuggerOutput >>= \output -> do
162161 -- > withAdaptor $ sendOutputEvent defaultOutputEvent { outputEventOutput = output }
163- -- >
162+ -- > ]
164163 --
165164 -> Adaptor app ()
166- registerNewDebugSession k v debuggerExecution outputEventSink = do
165+ registerNewDebugSession k v debuggerConcurrentActions = do
167166 store <- gets appStore
168167 adaptorStateMVar <- gets adaptorStateMVar
169168 debuggerThreadState <- liftIO $
170169 DebuggerThreadState
171- <$> fork debuggerExecution
172- <*> fork (outputEventSink (runAdaptorWith adaptorStateMVar))
170+ <$> sequence [fork $ action (runAdaptorWith adaptorStateMVar) | action <- debuggerConcurrentActions]
173171 liftIO . atomically $ modifyTVar' store (H. insert k (debuggerThreadState, v))
174172 setDebugSessionId k
175173 logInfo $ BL8. pack $ " Registered new debug session: " <> unpack k
@@ -210,8 +208,7 @@ destroyDebugSession = do
210208 (sessionId, DebuggerThreadState {.. }, _) <- getDebugSessionWithThreadIdAndSessionId
211209 store <- getAppStore
212210 liftIO $ do
213- killThread debuggerThread
214- killThread debuggerOutputEventThread
211+ mapM_ killThread debuggerThreads
215212 atomically $ modifyTVar' store (H. delete sessionId)
216213 logInfo $ BL8. pack $ " SessionId " <> unpack sessionId <> " ended"
217214----------------------------------------------------------------------------
0 commit comments