diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-20 01:09:54 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-20 01:09:54 +0400 |
commit | 17949276fbd32ab75bcb18016210b6947df54ed1 (patch) | |
tree | 3ecf7756b345b8c5803ba2078c556ba409e721c2 /src/Network/BitTorrent/Internal | |
parent | 14ebe9b9dd4fc5415b2c77e08e02c175996113ef (diff) |
Expose multitracker session state
Diffstat (limited to 'src/Network/BitTorrent/Internal')
-rw-r--r-- | src/Network/BitTorrent/Internal/Cache.hs | 5 |
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 | |||
35 | import Data.Default | 36 | import Data.Default |
36 | import Data.Time | 37 | import Data.Time |
37 | import Data.Time.Clock.POSIX | 38 | import Data.Time.Clock.POSIX |
39 | import System.IO.Unsafe | ||
38 | 40 | ||
39 | 41 | ||
40 | data Cached a = Cached | 42 | data 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 | ||
148 | unsafeTryTakeData :: Cached a -> Maybe a | ||
149 | unsafeTryTakeData = unsafePerformIO . tryTakeData | ||
150 | |||
146 | invalidateData :: Cached a -> IO a -> IO (Cached a) | 151 | invalidateData :: Cached a -> IO a -> IO (Cached a) |
147 | invalidateData Cached {..} action = do | 152 | invalidateData Cached {..} action = do |
148 | t <- getPOSIXTime | 153 | t <- getPOSIXTime |