From fa30a4f0e59d70f24aadc31b352a8d3699638430 Mon Sep 17 00:00:00 2001 From: Marius Ghita Date: Thu, 23 Apr 2020 20:22:02 +0300 Subject: [PATCH 1/2] TChan documentation newBroadcastTChan example Current example currently does not work as dupTChan runs inside the STM monad, not IO --- Control/Concurrent/STM/TChan.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Control/Concurrent/STM/TChan.hs b/Control/Concurrent/STM/TChan.hs index a8c28c1..79cc668 100644 --- a/Control/Concurrent/STM/TChan.hs +++ b/Control/Concurrent/STM/TChan.hs @@ -86,7 +86,7 @@ newTChanIO = do -- -- >serve :: TChan Message -> Client -> IO loop -- >serve broadcastChan client = do --- > myChan <- dupTChan broadcastChan +-- > myChan <- atomically $ dupTChan broadcastChan -- > forever $ do -- > message <- readTChan myChan -- > send client message From 6f67beeef604e92e9ec1895f023ece3b35cff5dc Mon Sep 17 00:00:00 2001 From: Marius Ghita Date: Thu, 23 Apr 2020 20:26:47 +0300 Subject: [PATCH 2/2] TChan documentation newBroadcastTChan example atomically call is required for readTChan --- Control/Concurrent/STM/TChan.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Control/Concurrent/STM/TChan.hs b/Control/Concurrent/STM/TChan.hs index 79cc668..6fa090f 100644 --- a/Control/Concurrent/STM/TChan.hs +++ b/Control/Concurrent/STM/TChan.hs @@ -88,7 +88,7 @@ newTChanIO = do -- >serve broadcastChan client = do -- > myChan <- atomically $ dupTChan broadcastChan -- > forever $ do --- > message <- readTChan myChan +-- > message <- atomically $ readTChan myChan -- > send client message -- -- The problem with using 'newTChan' to create the broadcast channel is that if