diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-23 23:05:51 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-23 23:41:03 +0000 |
commit | 9d66c754088fd935e56ad2bdd91721ba93e809a7 (patch) | |
tree | aa3928f3b67f677790366ac1f433be8ba4990ee8 /src/Data/Word64RangeMap.hs | |
parent | 16851ba2417933dd83ee1e7b91964e7e58b78d85 (diff) |
rangemap integration
Conflicts:
dht-client.cabal
src/Network/Tox/Crypto/Handlers.hs
Diffstat (limited to 'src/Data/Word64RangeMap.hs')
-rw-r--r-- | src/Data/Word64RangeMap.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Data/Word64RangeMap.hs b/src/Data/Word64RangeMap.hs index b5cbe9d1..c754c226 100644 --- a/src/Data/Word64RangeMap.hs +++ b/src/Data/Word64RangeMap.hs | |||
@@ -15,6 +15,8 @@ import Data.Array.MArray (MArray(..)) | |||
15 | import qualified Data.Array.Base as Base | 15 | import qualified Data.Array.Base as Base |
16 | import Data.Reference | 16 | import Data.Reference |
17 | import Debug.Trace | 17 | import Debug.Trace |
18 | import Control.Concurrent.STM | ||
19 | import Control.Concurrent.STM.TArray | ||
18 | import Data.Array.IO | 20 | import Data.Array.IO |
19 | import Data.IORef | 21 | import Data.IORef |
20 | 22 | ||
@@ -58,6 +60,11 @@ instance (Reference r m, MArray ma e m) => MArray (RefArray r ma) e m where | |||
58 | unsafeWrite (RefArray r) i e = modifyRef r (\x -> Base.unsafeWrite x i e >> return (x,())) | 60 | unsafeWrite (RefArray r) i e = modifyRef r (\x -> Base.unsafeWrite x i e >> return (x,())) |
59 | -} | 61 | -} |
60 | 62 | ||
63 | emptySTMRangeMap :: STM (RangeMap TArray Word8 TVar) | ||
64 | emptySTMRangeMap = RefArray <$> | ||
65 | (newTVar =<< | ||
66 | newListArray (0,-1) []) | ||
67 | |||
61 | -- | a sample RangeMap for easier debugging | 68 | -- | a sample RangeMap for easier debugging |
62 | getX :: IO (RangeMap IOArray Word8 IORef) | 69 | getX :: IO (RangeMap IOArray Word8 IORef) |
63 | getX = RefArray <$> | 70 | getX = RefArray <$> |