concurrent-hashtable 0.1.0 → 0.1.1
raw patch · 2 files changed
+10/−22 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.HashTable.Internal: readChainForKey :: HashTable k v -> k -> STM (Chain k v)
Files
concurrent-hashtable.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 52e913bb36c726771c6a1d52ff86abb22578db4f327354ec03258c126f660c66+-- hash: f8119720fafe38e62a12ec4438f8fac609ac78976b248f0ecb39515f8edaf064 name: concurrent-hashtable-version: 0.1.0+version: 0.1.1 synopsis: Thread-safe hash tables for multi-cores! description: Please see the README on GitHub at <https://github.com/pwrobinson/concurrent-hashtable#readme> category: Concurrency
src/Data/HashTable/Internal.hs view
@@ -172,7 +172,7 @@ | (k,v) <- listOfNodes ] -- debug ("finished migrate for list ",idx) --- | Lookup the value for a key in the hash table.+-- | Lookup the value for the key in the hash table if it exists. {-# INLINABLE lookup #-} lookup :: (Eq k) => HashTable k v -> k -> IO (Maybe v) lookup htable k = do@@ -247,7 +247,7 @@ else return False --- Deletes the entry for the given key from the hash table. Returns `True` if and only if an entry was deleted from the table.+-- | Deletes the entry for the given key from the hash table. Returns `True` if and only if an entry was deleted from the table. delete :: (Eq k) => HashTable k v -> k -- ^ key of entry that will be deleted@@ -299,28 +299,16 @@ deleteFirstKey _ [] = [] deleteFirstKey x (y:ys) = if x == fst y then ys else y : deleteFirstKey x ys +-- | Read the chain for the given key. {-# INLINABLE readChainForKeyIO #-}--- | Get the chain for the given key. readChainForKeyIO :: HashTable k v -> k -> IO (Chain k v) readChainForKeyIO htable k = do- size1 <- readSizeIO htable- let index = (_hashFunc (_config htable) k) `mod` size1- chain <- readChainForIndexIO htable index- size2 <- readSizeIO htable- if size1 /= size2 then- readChainForKeyIO htable k- else- return chain--{-# INLINABLE readChainForKey #-}--- | Get the chain for the given key.-readChainForKey :: HashTable k v -> k -> STM (Chain k v)-readChainForKey htable k = do- size1 <- readSize htable- let index = (_hashFunc (_config htable) k) `mod` size1- readChainForIndex htable index+ chainsVec <- readTVarIO $ _chainsVecTV htable+ let size = V.length chainsVec+ let index = (_hashFunc (_config htable) k) `mod` size+ return $ chainsVec ! index --- | Get the chain for the given index (warning: bounds are not checked)+-- | Read the chain for the given index (warning: bounds are not checked) {-# INLINABLE readChainForIndexIO #-} readChainForIndexIO :: HashTable k v -> Int -> IO (Chain k v) readChainForIndexIO htable idx = do