Skip to content

Commit

Permalink
create Moment.now
Browse files Browse the repository at this point in the history
  • Loading branch information
sullyj3 committed Aug 4, 2024
1 parent 1a23f39 commit d813d5d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Sand/SandClient.lean
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def handleCmd (server : Socket) (cmd : Command) : IO Unit := do
| .timerNotFound => timerNotFound timerId
| Command.list => do
let .ok timers := resp
let now ← Moment.mk <$> IO.monoMsNow
let now ← Moment.now
IO.println <| showTimers timers.data now
| Command.pauseTimer which => match resp with
| .ok =>
Expand Down
2 changes: 1 addition & 1 deletion src/Sand/SandDaemon.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ def SandDaemon.main (_args : List String) : IO α := do
forever do
let (client, _clientAddr) ← sock.accept
let _tsk ← IO.asTask (prio := .dedicated) <| do
let clientConnectedTime ← Moment.mk <$> IO.monoMsNow
let clientConnectedTime ← Moment.now
let env := {state, client, clientConnectedTime, soundPath?}
handleClient env
2 changes: 1 addition & 1 deletion src/Sand/SandDaemon/HandleCommand.lean
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private partial def countdown (id : TimerId) (due : Moment) : CmdHandlerT IO Uni
loop
where
loop := do
let now ← Moment.mk <$> IO.monoMsNow
let now ← Moment.now
let remaining := due - now
-- This task will be cancelled if the timer is cancelled or paused.
-- in case of resumed, a new separate task will be spawned.
Expand Down
2 changes: 2 additions & 0 deletions src/Sand/Time.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ structure Moment where
millis : Nat
deriving Repr, ToJson, FromJson, BEq

def Moment.now : IO Moment := Moment.mk <$> IO.monoMsNow

structure Duration where
millis : Nat
deriving Repr, ToJson, FromJson, BEq
Expand Down

0 comments on commit d813d5d

Please sign in to comment.