add wait for empty reporting channel before closing

main
Ben Grewell 4 years ago
parent 2327d13022
commit 1dd7340d4b

@ -2,7 +2,6 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment=""> <list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/reporter.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/reporter.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />

@ -2,6 +2,7 @@ package iperf
import ( import (
"github.com/BGrewell/tail" "github.com/BGrewell/tail"
"time"
) )
type Reporter struct { type Reporter struct {
@ -24,6 +25,7 @@ func (r *Reporter) Stop() {
if len(r.ReportingChannel) == 0 { if len(r.ReportingChannel) == 0 {
break break
} }
time.Sleep(1 * time.Millisecond)
} }
close(r.ReportingChannel) close(r.ReportingChannel)
} }

Loading…
Cancel
Save