Created
February 2, 2017 18:05
-
-
Save hwayne/1a58b964c10b3a067170bb996e47a78e to your computer and use it in GitHub Desktop.
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
---- MODULE logger ---- | |
EXTENDS Integers, TLC, Sequences | |
Files == { "a" } | |
FileStruct == [ requested : BOOLEAN, uploaded : {FALSE}, logged : {FALSE}, downloaded : {FALSE}] | |
Range(F) == { F[x]: x \in DOMAIN F } | |
(* --algorithm logger | |
variables files \in [Files -> FileStruct]; | |
define | |
FileProc(proc) == [ f : Files, p : {proc} ] | |
end define; | |
process upload \in FileProc("upload") | |
begin | |
Upload: | |
if files[self.f].requested then | |
files[self.f].uploaded := TRUE | |
end if | |
end process; | |
process log \in FileProc("log") | |
begin | |
Log: | |
await files[self.f].uploaded; | |
files[self.f].logged := TRUE | |
end process; | |
process download \in FileProc("download") | |
begin | |
Download: | |
await files[self.f].uploaded; | |
files[self.f].downloaded := TRUE || | |
files[self.f].uploaded := FALSE | |
end process; | |
end algorithm; *) | |
\* BEGIN TRANSLATION | |
\* END TRANSLATION | |
DownloadInvariant == | |
\A f \in Files: | |
/\ files[f].downloaded => files[f].requested | |
/\ files[f].downloaded => ~files[f].uploaded | |
LoggingInvariant == | |
\A f \in Files: | |
/\ files[f].downloaded => files[f].logged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment