netserver/Miscutils.hs
changeset 852 f756a1d3324c
parent 851 8ffa4ad0d8ea
child 889 3bf9dc791f45
equal deleted inserted replaced
851:8ffa4ad0d8ea 852:f756a1d3324c
    40 manipState state op =
    40 manipState state op =
    41 	atomically $ do
    41 	atomically $ do
    42 			ls <- readTVar state
    42 			ls <- readTVar state
    43 			writeTVar state $ op ls
    43 			writeTVar state $ op ls
    44 
    44 
    45 manipState2 :: TVar[ClientInfo] -> TVar[RoomInfo] -> ([ClientInfo] -> [RoomInfo] -> ([ClientInfo], [RoomInfo])) -> IO()
    45 manipState2 :: TVar[ClientInfo] -> TVar[RoomInfo] -> ([ClientInfo] -> [RoomInfo] -> ([ClientInfo], [RoomInfo], Bool)) -> IO Bool
    46 manipState2 state1 state2 op =
    46 manipState2 state1 state2 op =
    47 	atomically $ do
    47 	atomically $ do
    48 			ls1 <- readTVar state1
    48 			ls1 <- readTVar state1
    49 			ls2 <- readTVar state2
    49 			ls2 <- readTVar state2
    50 			let (ol1, ol2) = op ls1 ls2
    50 			let (ol1, ol2, res) = op ls1 ls2
    51 			writeTVar state1 ol1
    51 			writeTVar state1 ol1
    52 			writeTVar state2 ol2
    52 			writeTVar state2 ol2
       
    53 			return res
    53 	
    54