File tree 1 file changed +11
-18
lines changed
1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -49,20 +49,14 @@ type tokenCompletor interface {
49
49
type baseToken struct {
50
50
m sync.RWMutex
51
51
complete chan struct {}
52
- ready bool
53
52
err error
54
53
}
55
54
56
55
// Wait will wait indefinitely for the Token to complete, ie the Publish
57
56
// to be sent and confirmed receipt from the broker
58
57
func (b * baseToken ) Wait () bool {
59
- b .m .Lock ()
60
- defer b .m .Unlock ()
61
- if ! b .ready {
62
- <- b .complete
63
- b .ready = true
64
- }
65
- return b .ready
58
+ <- b .complete
59
+ return true
66
60
}
67
61
68
62
// WaitTimeout takes a time.Duration to wait for the flow associated with the
@@ -73,18 +67,17 @@ func (b *baseToken) WaitTimeout(d time.Duration) bool {
73
67
b .m .Lock ()
74
68
defer b .m .Unlock ()
75
69
76
- if ! b .ready {
77
- timer := time .NewTimer (d )
78
- select {
79
- case <- b .complete :
80
- b .ready = true
81
- if ! timer .Stop () {
82
- <- timer .C
83
- }
84
- case <- timer .C :
70
+ timer := time .NewTimer (d )
71
+ select {
72
+ case <- b .complete :
73
+ if ! timer .Stop () {
74
+ <- timer .C
85
75
}
76
+ return true
77
+ case <- timer .C :
86
78
}
87
- return b .ready
79
+
80
+ return false
88
81
}
89
82
90
83
func (b * baseToken ) flowComplete () {
You can’t perform that action at this time.
0 commit comments