gameServer/Store.hs
changeset 3673 45778b16b224
parent 3671 a94d1dc4a8d9
child 3741 73246d25dfe1
equal deleted inserted replaced
3671:a94d1dc4a8d9 3673:45778b16b224
    75 
    75 
    76 
    76 
    77 removeElem :: MStore e -> ElemIndex -> IO ()
    77 removeElem :: MStore e -> ElemIndex -> IO ()
    78 removeElem (MStore ref) (ElemIndex n) = do
    78 removeElem (MStore ref) (ElemIndex n) = do
    79     (busyElems, freeElems, arr) <- readIORef ref
    79     (busyElems, freeElems, arr) <- readIORef ref
    80     IOA.writeArray arr n (error "Store: no element")
    80     IOA.writeArray arr n (error $ "Store: no element " ++ show n)
    81     writeIORef ref (IntSet.delete n busyElems, IntSet.insert n freeElems, arr)
    81     writeIORef ref (IntSet.delete n busyElems, IntSet.insert n freeElems, arr)
    82 
    82 
    83 
    83 
    84 readElem :: MStore e -> ElemIndex -> IO e
    84 readElem :: MStore e -> ElemIndex -> IO e
    85 readElem (MStore ref) (ElemIndex n) = readIORef ref >>= \(_, _, arr) -> IOA.readArray arr n
    85 readElem (MStore ref) (ElemIndex n) = readIORef ref >>= \(_, _, arr) -> IOA.readArray arr n