-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathporcupine.go
48 lines (41 loc) · 1.77 KB
/
porcupine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package porcupine
import "time"
// CheckOperations checks whether a history is linearizable.
func CheckOperations(model Model, history []Operation) bool {
res, _ := checkOperations(model, history, false, 0)
return res == Ok
}
// CheckOperationsTimeout checks whether a history is linearizable, with a
// timeout.
//
// A timeout of 0 is interpreted as an unlimited timeout.
func CheckOperationsTimeout(model Model, history []Operation, timeout time.Duration) CheckResult {
res, _ := checkOperations(model, history, false, timeout)
return res
}
// CheckOperationsVerbose checks whether a history is linearizable while
// computing data that can be used to visualize the history and linearization.
//
// The returned LinearizationInfo can be used with [Visualize].
func CheckOperationsVerbose(model Model, history []Operation, timeout time.Duration) (CheckResult, LinearizationInfo) {
return checkOperations(model, history, true, timeout)
}
// CheckEvents checks whether a history is linearizable.
func CheckEvents(model Model, history []Event) bool {
res, _ := checkEvents(model, history, false, 0)
return res == Ok
}
// CheckEventsTimeout checks whether a history is linearizable, with a timeout.
//
// A timeout of 0 is interpreted as an unlimited timeout.
func CheckEventsTimeout(model Model, history []Event, timeout time.Duration) CheckResult {
res, _ := checkEvents(model, history, false, timeout)
return res
}
// CheckEventsVerbose checks whether a history is linearizable while computing
// data that can be used to visualize the history and linearization.
//
// The returned LinearizationInfo can be used with [Visualize].
func CheckEventsVerbose(model Model, history []Event, timeout time.Duration) (CheckResult, LinearizationInfo) {
return checkEvents(model, history, true, timeout)
}