feat: Run cancel token with timeout

This commit is contained in:
Leni Aniva 2025-03-28 19:06:43 -07:00
parent 48485a868b
commit be505b8050
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
1 changed files with 11 additions and 0 deletions

View File

@ -3,7 +3,10 @@ import Pantograph.Goal
import Pantograph.Protocol import Pantograph.Protocol
import Pantograph.Delate import Pantograph.Delate
import Pantograph.Version import Pantograph.Version
import Lean import Lean
import Std.Time
import Std.Internal.Async
namespace Lean namespace Lean
@ -212,4 +215,12 @@ def goalConvExit (state: GoalState): CoreM TacticResult :=
def goalCalc (state: GoalState) (goal: MVarId) (pred: String): CoreM TacticResult := def goalCalc (state: GoalState) (goal: MVarId) (pred: String): CoreM TacticResult :=
runTermElabM <| state.tryCalc goal pred runTermElabM <| state.tryCalc goal pred
-- Cancel the token after a timeout.
@[export pantograph_run_cancel_token_with_timeout_m]
def runCancelTokenWithTimeout (cancelToken : IO.CancelToken) (timeout : Std.Time.Millisecond.Offset) : IO Unit := do
let _ ← EIO.asTask do
let () ← (← Std.Internal.IO.Async.sleep timeout).block
cancelToken.set
return ()
end Pantograph end Pantograph