diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/KRPC.hs | 1 | ||||
-rw-r--r-- | src/Network/KRPC/Manager.hs | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/Network/KRPC.hs b/src/Network/KRPC.hs index 69a4efca..3b722ac2 100644 --- a/src/Network/KRPC.hs +++ b/src/Network/KRPC.hs | |||
@@ -59,6 +59,7 @@ module Network.KRPC | |||
59 | -- ** Query | 59 | -- ** Query |
60 | , QueryFailure (..) | 60 | , QueryFailure (..) |
61 | , query | 61 | , query |
62 | , getQueryCount | ||
62 | 63 | ||
63 | -- ** Handler | 64 | -- ** Handler |
64 | , HandlerFailure (..) | 65 | , HandlerFailure (..) |
diff --git a/src/Network/KRPC/Manager.hs b/src/Network/KRPC/Manager.hs index 468744c1..e2b60b6a 100644 --- a/src/Network/KRPC/Manager.hs +++ b/src/Network/KRPC/Manager.hs | |||
@@ -29,6 +29,7 @@ module Network.KRPC.Manager | |||
29 | -- * Queries | 29 | -- * Queries |
30 | , QueryFailure (..) | 30 | , QueryFailure (..) |
31 | , query | 31 | , query |
32 | , getQueryCount | ||
32 | 33 | ||
33 | -- * Handlers | 34 | -- * Handlers |
34 | , HandlerFailure (..) | 35 | , HandlerFailure (..) |
@@ -232,6 +233,13 @@ genTransactionId ref = do | |||
232 | cur <- atomicModifyIORef' ref $ \ cur -> (succ cur, cur) | 233 | cur <- atomicModifyIORef' ref $ \ cur -> (succ cur, cur) |
233 | return $ BC.pack (show cur) | 234 | return $ BC.pack (show cur) |
234 | 235 | ||
236 | -- | How many times 'query' call have been performed. | ||
237 | getQueryCount :: MonadKRPC h m => m Int | ||
238 | getQueryCount = do | ||
239 | Manager {..} <- getManager | ||
240 | curTrans <- liftIO $ readIORef transactionCounter | ||
241 | return $ curTrans - optSeedTransaction options | ||
242 | |||
235 | registerQuery :: CallId -> PendingCalls -> IO CallRes | 243 | registerQuery :: CallId -> PendingCalls -> IO CallRes |
236 | registerQuery cid ref = do | 244 | registerQuery cid ref = do |
237 | ares <- newEmptyMVar | 245 | ares <- newEmptyMVar |