diff -r af8390d807d6 -r a3159a410e5c gameServer/Store.hs --- a/gameServer/Store.hs Sun Jun 06 15:29:33 2010 +0000 +++ b/gameServer/Store.hs Sun Jun 06 19:03:06 2010 +0000 @@ -9,6 +9,7 @@ writeElem, modifyElem, firstIndex, + indicesM, withIStore, withIStore2, (!), @@ -94,6 +95,12 @@ IOA.readArray arr n >>= (IOA.writeArray arr n) . f +indicesM :: MStore e -> IO [ElemIndex] +indicesM (MStore ref) = do + (busy, _, _) <- readIORef ref + return $ map ElemIndex $ IntSet.toList busy + + -- A way to use see MStore elements in pure code via IStore m2i :: MStore e -> IO (IStore e) m2i (MStore ref) = do @@ -101,6 +108,7 @@ c <- IOA.unsafeFreeze c' return $ IStore (a, c) + withIStore :: MStore e -> (IStore e -> a) -> IO a withIStore m f = liftM f (m2i m)