summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Internal
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-03-20 01:09:54 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-03-20 01:09:54 +0400
commit17949276fbd32ab75bcb18016210b6947df54ed1 (patch)
tree3ecf7756b345b8c5803ba2078c556ba409e721c2 /src/Network/BitTorrent/Internal
parent14ebe9b9dd4fc5415b2c77e08e02c175996113ef (diff)
Expose multitracker session state
Diffstat (limited to 'src/Network/BitTorrent/Internal')
-rw-r--r--src/Network/BitTorrent/Internal/Cache.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Internal/Cache.hs b/src/Network/BitTorrent/Internal/Cache.hs
index 1eb2f192..8c74467a 100644
--- a/src/Network/BitTorrent/Internal/Cache.hs
+++ b/src/Network/BitTorrent/Internal/Cache.hs
@@ -27,6 +27,7 @@ module Network.BitTorrent.Internal.Cache
27 27
28 -- * Cached data 28 -- * Cached data
29 , tryTakeData 29 , tryTakeData
30 , unsafeTryTakeData
30 , takeData 31 , takeData
31 ) where 32 ) where
32 33
@@ -35,6 +36,7 @@ import Data.Monoid
35import Data.Default 36import Data.Default
36import Data.Time 37import Data.Time
37import Data.Time.Clock.POSIX 38import Data.Time.Clock.POSIX
39import System.IO.Unsafe
38 40
39 41
40data Cached a = Cached 42data Cached a = Cached
@@ -143,6 +145,9 @@ tryTakeData c = do
143 alive <- isAlive c 145 alive <- isAlive c
144 return $ if alive then Just (cachedData c) else Nothing 146 return $ if alive then Just (cachedData c) else Nothing
145 147
148unsafeTryTakeData :: Cached a -> Maybe a
149unsafeTryTakeData = unsafePerformIO . tryTakeData
150
146invalidateData :: Cached a -> IO a -> IO (Cached a) 151invalidateData :: Cached a -> IO a -> IO (Cached a)
147invalidateData Cached {..} action = do 152invalidateData Cached {..} action = do
148 t <- getPOSIXTime 153 t <- getPOSIXTime