From 80fb3d85b2b9a30e8b717dc63aaca75d346f5667 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 12 Apr 2017 16:01:00 -0400 Subject: simulate laggy network --- Types.hs | 2 +- debug-me.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Types.hs b/Types.hs index 3061ba6..33df35c 100644 --- a/Types.hs +++ b/Types.hs @@ -1,7 +1,7 @@ module Types where import Data.ByteString -import Crypto.Hash as H +import qualified Crypto.Hash as H -- | Things that the developer sees. data Seen = Seen diff --git a/debug-me.hs b/debug-me.hs index 4122881..a0d7476 100644 --- a/debug-me.hs +++ b/debug-me.hs @@ -6,6 +6,7 @@ import Types import Hash import Pty +import Control.Concurrent import Control.Concurrent.Async import Control.Concurrent.STM import System.IO @@ -34,6 +35,9 @@ main = do cancel uthread return exitstatus +networkDelay :: IO () +networkDelay = threadDelay 1000000 + developer :: TChan (Activity Entered) -> TChan (Activity Seen) -> IO () developer ichan ochan = do startact <- atomically $ readTChan ochan @@ -147,6 +151,7 @@ sendPtyInput ichan p backlog = go where Master h = ptyMaster p go = do + networkDelay mb <- atomically $ do newact <- readTChan ichan bl <- readTVar backlog -- cgit v1.2.3