Skip to content

Bufferflowtimed #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Release resources when stopped
  • Loading branch information
matteosuppo committed Sep 29, 2015
commit 00249d2305c0a9117d299cbb52bbd44cde8c1866
8 changes: 5 additions & 3 deletions bufferflow_timed.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type BufferflowTimed struct {
Port string
Output chan []byte
Input chan string
ticker *time.Ticker
}

var (
Expand All @@ -28,9 +29,8 @@ func (b *BufferflowTimed) Init() {
}()

go func() {
c := time.Tick(16 * time.Millisecond)
log.Println(bufferedOutput)
for _ = range c {
b.ticker = time.NewTicker(16 * time.Millisecond)
for _ = range b.ticker.C {
m := SpPortMessage{bufferedOutput}
buf, _ := json.Marshal(m)
b.Output <- []byte(buf)
Expand Down Expand Up @@ -93,4 +93,6 @@ func (b *BufferflowTimed) IsBufferGloballySendingBackIncomingData() bool {
}

func (b *BufferflowTimed) Close() {
b.ticker.Stop()
close(b.Input)
}