-
Notifications
You must be signed in to change notification settings - Fork 4
/
sync_ever.go
51 lines (39 loc) · 1.25 KB
/
sync_ever.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
49
50
51
package smsync
import (
"github.com/insolar/assured-ledger/ledger-core/conveyor/smachine"
"github.com/insolar/assured-ledger/ledger-core/vanilla/throw"
)
func NewAlwaysOpen(name string) smachine.SyncLink {
return smachine.NewSyncLink(&openLock{name: name})
}
type openLock struct {
name string
}
func (p *openLock) CheckState() smachine.BoolDecision {
return true
}
func (p *openLock) UseDependency(smachine.SlotDependency, smachine.SlotDependencyFlags) smachine.Decision {
return smachine.Impossible
}
func (p *openLock) ReleaseDependency(dep smachine.SlotDependency) (bool, smachine.SlotDependency, []smachine.PostponedDependency, []smachine.StepLink) {
pd, sl := dep.ReleaseAll()
return true, nil, pd, sl
}
func (p *openLock) CreateDependency(smachine.SlotLink, smachine.SlotDependencyFlags) (smachine.BoolDecision, smachine.SlotDependency) {
return true, nil
}
func (p *openLock) GetLimit() (limit int, isAdjustable bool) {
return 1, false
}
func (p *openLock) AdjustLimit(int, bool) ([]smachine.StepLink, bool) {
panic(throw.IllegalState())
}
func (p *openLock) GetCounts() (active, inactive int) {
return -1, 0
}
func (p *openLock) GetName() string {
return p.name
}
func (p *openLock) EnumQueues(smachine.EnumQueueFunc) bool {
return false
}