@@ -144,10 +144,9 @@ setDebugSessionId session = modify' $ \s -> s { sessionId = Just session }
144
144
registerNewDebugSession
145
145
:: SessionId
146
146
-> 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
151
150
-- the debugger to emit events and for the adaptor to forward to the editor
152
151
-- This function should be in a 'forever' loop waiting on the read end of
153
152
-- a debugger channel.
@@ -157,19 +156,18 @@ registerNewDebugSession
157
156
-- used when sending events to the editor from the debugger (or from any forked thread).
158
157
--
159
158
-- >
160
- -- > registerNewDebugSession sessionId appState loadDebugger $ \withAdaptor ->
159
+ -- > registerNewDebugSession sessionId appState $ loadDebugger : [ \withAdaptor ->
161
160
-- > forever $ getDebuggerOutput >>= \output -> do
162
161
-- > withAdaptor $ sendOutputEvent defaultOutputEvent { outputEventOutput = output }
163
- -- >
162
+ -- > ]
164
163
--
165
164
-> Adaptor app ()
166
- registerNewDebugSession k v debuggerExecution outputEventSink = do
165
+ registerNewDebugSession k v debuggerConcurrentActions = do
167
166
store <- gets appStore
168
167
adaptorStateMVar <- gets adaptorStateMVar
169
168
debuggerThreadState <- liftIO $
170
169
DebuggerThreadState
171
- <$> fork debuggerExecution
172
- <*> fork (outputEventSink (runAdaptorWith adaptorStateMVar))
170
+ <$> sequence [fork $ action (runAdaptorWith adaptorStateMVar) | action <- debuggerConcurrentActions]
173
171
liftIO . atomically $ modifyTVar' store (H. insert k (debuggerThreadState, v))
174
172
setDebugSessionId k
175
173
logInfo $ BL8. pack $ " Registered new debug session: " <> unpack k
@@ -210,8 +208,7 @@ destroyDebugSession = do
210
208
(sessionId, DebuggerThreadState {.. }, _) <- getDebugSessionWithThreadIdAndSessionId
211
209
store <- getAppStore
212
210
liftIO $ do
213
- killThread debuggerThread
214
- killThread debuggerOutputEventThread
211
+ mapM_ killThread debuggerThreads
215
212
atomically $ modifyTVar' store (H. delete sessionId)
216
213
logInfo $ BL8. pack $ " SessionId " <> unpack sessionId <> " ended"
217
214
----------------------------------------------------------------------------
0 commit comments