issueNRequests :: CL.MasterHandle -> Int -> [MVar ()] -> IO ([MVar ()])
issueNRequests mH n mvars
  | n == 0 = return mvars
  | otherwise = do
    let request = createRequest (n*3)
    m <- newEmptyMVar 
    tid <- forkFinally (case request of
                      (Left k) -> do
                        CL.getVal mH k
                        return ()
                      (Right (k,v)) -> do 
                        CL.putVal mH k v
                        return ()
                  ) (\_ -> putMVar m ())

    threadDelay 50000
    issueNRequests mH (n - 1) (mvars ++ [m])
issueNRequests :: CL.MasterHandle -> Int -> [MVar ()] -> IO ([MVar ()])
issueNRequests mH n mvars
  | n == 0 = return mvars
  | otherwise = do
    let request = createRequest (n*3)
    m <- newEmptyMVar 
    tid <- forkFinally (case request of
                      (Left k) -> do
                        CL.getVal mH k
                        return ()
                      (Right (k,v)) -> do 
                        CL.putVal mH k v
                        return ()
                  ) (\_ -> putMVar m ())

    threadDelay 50000
    issueNRequests mH (n - 1) (mvars ++ [m])
issueNRequests mH n mvars
  | n == 0 = return mvars
  | otherwise = do
    let request = createRequest (n*3)
    m <- newEmptyMVar 
    tid <- forkFinally (case request of
                      (Left k) -> do
                        CL.getVal mH k
                        return ()
                      (Right (k,v)) -> do 
                        CL.putVal mH k v
                        return ()
                  ) (\_ -> putMVar m ())

    threadDelay 50000
    issueNRequests mH (n - 1) (mvars ++ [m])