Skip to content

Commit

Permalink
rename supply to counter
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Sep 27, 2023
1 parent 1f03db5 commit 986268f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions src/TimerWheel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import GHC.Exception (errorCallException)
import qualified Ki
import TimerWheel.Internal.Config (Config)
import qualified TimerWheel.Internal.Config as Config
import TimerWheel.Internal.Counter (Counter, incrCounter, newCounter)
import TimerWheel.Internal.Micros (Micros (Micros))
import qualified TimerWheel.Internal.Micros as Micros
import TimerWheel.Internal.Supply (Counter, incrCounter, newCounter)
import TimerWheel.Internal.Wheel (Wheel)
import qualified TimerWheel.Internal.Wheel as Wheel

Expand Down Expand Up @@ -86,11 +86,10 @@ import qualified TimerWheel.Internal.Wheel as Wheel
--
-- @
data TimerWheel = TimerWheel
{ -- | A supply of unique ints.
supply :: {-# UNPACK #-} !Counter,
-- | The array of collections of timers.
{ -- A counter, to generate unique ints that identify registered actions.
counter :: {-# UNPACK #-} !Counter,
-- The array of collections of timers.
wheel :: {-# UNPACK #-} !Wheel
-- thread :: {-# UNPACK #-} !ThreadId
}

-- | Create a timer wheel in a scope.
Expand All @@ -102,9 +101,9 @@ create :: Ki.Scope -> Config -> IO TimerWheel
create scope config = do
validateConfig config
wheel <- Wheel.create (Config.spokes config) (Micros.fromFixed (Config.resolution config))
supply <- newCounter
counter <- newCounter
Ki.fork_ scope (Wheel.reap wheel)
pure TimerWheel {supply, wheel}
pure TimerWheel {counter, wheel}

-- | Perform an action with a timer wheel.
--
Expand Down Expand Up @@ -152,8 +151,8 @@ register_ wheel delay action = do
pure ()

registerImpl :: TimerWheel -> Micros -> IO () -> IO (IO Bool)
registerImpl TimerWheel {supply, wheel} delay action = do
key <- incrCounter supply
registerImpl TimerWheel {counter, wheel} delay action = do
key <- incrCounter counter
Wheel.insert wheel key delay action

-- | @recurring wheel action delay@ registers an action __@action@__ in timer wheel __@wheel@__ to fire every
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}

module TimerWheel.Internal.Supply
module TimerWheel.Internal.Counter
( Counter,
newCounter,
incrCounter,
Expand Down
2 changes: 1 addition & 1 deletion timer-wheel.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ library

other-modules:
TimerWheel.Internal.Config
TimerWheel.Internal.Counter
TimerWheel.Internal.Entries
TimerWheel.Internal.Micros
TimerWheel.Internal.Supply
TimerWheel.Internal.Timestamp
TimerWheel.Internal.Wheel

Expand Down

0 comments on commit 986268f

Please sign in to comment.