Skip to content

Commit

Permalink
label threads
Browse files Browse the repository at this point in the history
* timeout monitoring thread
* pipelined peer threads

This is useful for debugging, especially in sim.
  • Loading branch information
coot committed Oct 19, 2020
1 parent 751d793 commit 98d63b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion network-mux/src/Network/Mux/Timeout.hs
Expand Up @@ -308,7 +308,9 @@ monitoringThread :: (MonadFork m, MonadSTM m,
MonadMonotonicTime m, MonadTimer m,
MonadThrow (STM m))
=> MonitorState m -> m ()
monitoringThread monitorState@MonitorState{deadlineResetVar} =
monitoringThread monitorState@MonitorState{deadlineResetVar} = do
threadId <- myThreadId
labelThread threadId "timeout-monitoring-thread"
forever $ do
-- Grab the next timeout to consider
(tid, deadline, timeoutStateVar) <- readNextTimeout monitorState
Expand Down
17 changes: 13 additions & 4 deletions typed-protocols/src/Network/TypedProtocol/Driver.hs
Expand Up @@ -32,6 +32,7 @@ import Network.TypedProtocol.Pipelined

import Control.Monad.Class.MonadSTM
import Control.Monad.Class.MonadAsync
import Control.Monad.Class.MonadFork


-- $intro
Expand Down Expand Up @@ -224,7 +225,9 @@ data MaybeDState dstate (n :: N) where

runPipelinedPeerSender
:: forall ps (st :: ps) pr dstate c m a.
MonadSTM m
( MonadSTM m
, MonadThread m
)
=> TQueue m (ReceiveHandler dstate ps pr m c)
-> TQueue m (c, dstate)
-> Driver ps dstate m
Expand All @@ -233,7 +236,9 @@ runPipelinedPeerSender
-> m (a, dstate)
runPipelinedPeerSender receiveQueue collectQueue
Driver{sendMessage, recvMessage}
peer dstate0 =
peer dstate0 = do
threadId <- myThreadId
labelThread threadId "pipeliend-peer-seneder"
go Zero (HasDState dstate0) peer
where
go :: forall st' n.
Expand Down Expand Up @@ -275,13 +280,17 @@ runPipelinedPeerSender receiveQueue collectQueue

runPipelinedPeerReceiverQueue
:: forall ps pr dstate m c.
MonadSTM m
( MonadSTM m
, MonadThread m
)
=> TQueue m (ReceiveHandler dstate ps pr m c)
-> TQueue m (c, dstate)
-> Driver ps dstate m
-> m Void
runPipelinedPeerReceiverQueue receiveQueue collectQueue
driver@Driver{startDState} =
driver@Driver{startDState} = do
threadId <- myThreadId
labelThread threadId "pipelined-recevier-queue"
go startDState
where
go :: dstate -> m Void
Expand Down

0 comments on commit 98d63b6

Please sign in to comment.