File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ type Queue struct {
39
39
// sync is called for each item in the queue
40
40
sync func (interface {}) error
41
41
// workerDone is closed when the worker exits
42
- workerDone chan struct {}
42
+ workerDone chan bool
43
43
44
44
fn func (obj interface {}) (interface {}, error )
45
45
}
@@ -79,7 +79,9 @@ func (t *Queue) worker() {
79
79
for {
80
80
key , quit := t .queue .Get ()
81
81
if quit {
82
- close (t .workerDone )
82
+ if ! isClosed (t .workerDone ) {
83
+ close (t .workerDone )
84
+ }
83
85
return
84
86
}
85
87
@@ -95,6 +97,16 @@ func (t *Queue) worker() {
95
97
}
96
98
}
97
99
100
+ func isClosed (ch <- chan bool ) bool {
101
+ select {
102
+ case <- ch :
103
+ return true
104
+ default :
105
+ }
106
+
107
+ return false
108
+ }
109
+
98
110
// Shutdown shuts down the work queue and waits for the worker to ACK
99
111
func (t * Queue ) Shutdown () {
100
112
t .queue .ShutDown ()
@@ -117,7 +129,7 @@ func NewCustomTaskQueue(syncFn func(interface{}) error, fn func(interface{}) (in
117
129
q := & Queue {
118
130
queue : workqueue .NewRateLimitingQueue (workqueue .DefaultControllerRateLimiter ()),
119
131
sync : syncFn ,
120
- workerDone : make (chan struct {} ),
132
+ workerDone : make (chan bool ),
121
133
fn : fn ,
122
134
}
123
135
You can’t perform that action at this time.
0 commit comments