-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #660 from ejgallego/token_protect
[coq] Adapt `Coq.Protect` interface to incorporate an interruption token
- Loading branch information
Showing
8 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(* This is a wrapper for memprof-limits libs *) | ||
module type Intf = sig | ||
module Token : sig | ||
type t | ||
|
||
val create : unit -> t | ||
val set : t -> unit | ||
val is_set : t -> bool | ||
end | ||
|
||
val start : unit -> unit | ||
val limit : token:Token.t -> f:('a -> 'b) -> 'a -> ('b, exn) Result.t | ||
val name : string | ||
val available : bool | ||
end | ||
|
||
module Coq : Intf = struct | ||
module Token : sig | ||
type t | ||
|
||
val create : unit -> t | ||
val set : t -> unit | ||
val is_set : t -> bool | ||
end = struct | ||
type t = bool ref | ||
|
||
let create () = ref false | ||
|
||
let set t = | ||
t := true; | ||
Control.interrupt := true | ||
|
||
let is_set t = !t | ||
end | ||
|
||
let start () = () | ||
|
||
let limit ~token ~f x = | ||
if Token.is_set token then Error Sys.Break | ||
else | ||
let () = Control.interrupt := false in | ||
try Ok (f x) with Sys.Break -> Error Sys.Break | ||
|
||
let name = "Control.interrupt" | ||
let available = true | ||
end | ||
|
||
module Mp = Limits_mp_impl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(* This is a wrapper for memprof-limits libs *) | ||
module type Intf = sig | ||
module Token : sig | ||
type t | ||
|
||
val create : unit -> t | ||
val set : t -> unit | ||
val is_set : t -> bool | ||
end | ||
|
||
val start : unit -> unit | ||
val limit : token:Token.t -> f:('a -> 'b) -> 'a -> ('b, exn) Result.t | ||
val name : string | ||
val available : bool | ||
end | ||
|
||
module Coq : Intf | ||
module Mp : Intf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(* We'd like to move this code to Lang, but it is still too specific *) | ||
module Token = struct | ||
type t = unit | ||
|
||
let create () = () | ||
let set () = () | ||
let is_set () = false | ||
end | ||
|
||
let start () = () | ||
let limit ~token:_ ~f x = Result.Ok (f x) | ||
let name = "memprof-limits" | ||
let available = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(* We'd like to move this code to Lang, but it is still too specific *) | ||
module Token = Memprof_limits.Token | ||
|
||
let start () = Memprof_limits.start_memprof_limits () | ||
|
||
let limit ~token ~f x = | ||
let f () = f x in | ||
Memprof_limits.limit_with_token ~token f | ||
|
||
let name = "memprof-limits" | ||
let available = true |