Skip to content

Commit 1ffd9f2

Browse files
committed
Label mux threads
1 parent b0dda95 commit 1ffd9f2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

network-mux/src/Network/Mux.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ muxStart tracer (MuxApplication ptcls) bearer = do
177177

178178
muxerJob tq cnt =
179179
JobPool.Job (mux cnt MuxState { egressQueue = tq, Egress.bearer })
180-
MuxerException
180+
MuxerException "muxer"
181181

182182
demuxerJob tbl =
183183
JobPool.Job (demux DemuxState { dispatchTable = tbl, Ingress.bearer })
184-
DemuxerException
184+
DemuxerException "demuxer"
185185

186186
miniProtocolInitiatorJob = miniProtocolJob selectInitiator ModeInitiator
187187
miniProtocolResponderJob = miniProtocolJob selectResponder ModeResponder
@@ -216,6 +216,7 @@ muxStart tracer (MuxApplication ptcls) bearer = do
216216
where
217217
job run = JobPool.Job (jobAction run)
218218
(MiniProtocolException pnum pix pmode)
219+
((show pix) ++ "." ++ (show pmode))
219220

220221
jobAction run = do
221222
chan <- mkChannel

network-mux/src/Network/Mux/JobPool.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ data JobPool m a = JobPool {
2828
completionQueue :: !(TQueue m a)
2929
}
3030

31-
data Job m a = Job (m a) (SomeException -> a)
31+
data Job m a = Job (m a) (SomeException -> a) String
3232

3333
withJobPool :: forall m a b.
3434
(MonadAsync m, MonadThrow m)
@@ -52,12 +52,13 @@ forkJob :: forall m a.
5252
=> JobPool m a
5353
-> Job m a
5454
-> m ()
55-
forkJob JobPool{jobsVar, completionQueue} (Job action handler) =
55+
forkJob JobPool{jobsVar, completionQueue} (Job action handler label) =
5656
mask $ \restore -> do
5757
jobAsync <- async $ do
58+
tid <- myThreadId
59+
labelThread tid label
5860
res <- handleJust notAsyncExceptions (return . handler) $
5961
restore action
60-
tid <- myThreadId
6162
atomically $ do
6263
writeTQueue completionQueue res
6364
modifyTVar' jobsVar (Map.delete tid)

0 commit comments

Comments
 (0)