Skip to content

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Oct 11, 2024
1 parent 33a9e25 commit 264c633
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions warp/Network/Wai/Handler/Warp/Counter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ newCounter :: IO Counter
newCounter = Counter <$> newTVarIO 0

waitForZero :: Counter -> IO ()
waitForZero (Counter ref) = atomically $ do
x <- readTVar ref
waitForZero (Counter var) = atomically $ do
x <- readTVar var
when (x > 0) retry

waitForDecreased :: Counter -> IO ()
waitForDecreased (Counter ref) = do
n0 <- atomically $ readTVar ref
waitForDecreased (Counter var) = do
n0 <- atomically $ readTVar var
atomically $ do
n <- readTVar ref
n <- readTVar var
check (n < n0)

increase :: Counter -> IO ()
increase (Counter ref) = atomically $ modifyTVar' ref $ \x -> x + 1
increase (Counter var) = atomically $ modifyTVar' var $ \x -> x + 1

decrease :: Counter -> IO ()
decrease (Counter ref) = atomically $ modifyTVar' ref $ \x -> x - 1
decrease (Counter var) = atomically $ modifyTVar' var $ \x -> x - 1

0 comments on commit 264c633

Please sign in to comment.