File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package pipeline
16
16
17
17
import (
18
18
"fmt"
19
+ "sync"
19
20
20
21
"github.com/blinklabs-io/adder/event"
21
22
"github.com/blinklabs-io/adder/plugin"
@@ -29,6 +30,7 @@ type Pipeline struct {
29
30
outputChan chan event.Event
30
31
errorChan chan error
31
32
doneChan chan bool
33
+ wg sync.WaitGroup
32
34
}
33
35
34
36
func New () * Pipeline {
@@ -108,6 +110,7 @@ func (p *Pipeline) Start() error {
108
110
// Stop shuts down the pipeline and all plugins
109
111
func (p * Pipeline ) Stop () error {
110
112
close (p .doneChan )
113
+ p .wg .Wait ()
111
114
close (p .errorChan )
112
115
close (p .filterChan )
113
116
close (p .outputChan )
@@ -131,9 +134,11 @@ func (p *Pipeline) chanCopyLoop(
131
134
input <- chan event.Event ,
132
135
output chan <- event.Event ,
133
136
) {
137
+ p .wg .Add (1 )
134
138
for {
135
139
select {
136
140
case <- p .doneChan :
141
+ p .wg .Done ()
137
142
return
138
143
case evt , ok := <- input :
139
144
if ok {
@@ -146,9 +151,11 @@ func (p *Pipeline) chanCopyLoop(
146
151
147
152
// outputChanLoop reads events from the output channel and writes them to each output plugin's input channel
148
153
func (p * Pipeline ) outputChanLoop () {
154
+ p .wg .Add (1 )
149
155
for {
150
156
select {
151
157
case <- p .doneChan :
158
+ p .wg .Done ()
152
159
return
153
160
case evt , ok := <- p .outputChan :
154
161
if ok {
You can’t perform that action at this time.
0 commit comments