Skip to content

Commit

Permalink
Changed op.notify<-true to close(op.notify).
Browse files Browse the repository at this point in the history
  • Loading branch information
yifan-gu committed Jul 15, 2014
1 parent 314eb1a commit 90cc060
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/apiserver/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Operation struct {
awaiting <-chan interface{}
finished *time.Time
lock sync.Mutex
notify chan bool
notify chan struct{}
}

// Operations tracks all the ongoing operations.
Expand Down Expand Up @@ -62,7 +62,7 @@ func (ops *Operations) NewOperation(from <-chan interface{}) *Operation {
op := &Operation{
ID: strconv.FormatInt(id, 10),
awaiting: from,
notify: make(chan bool, 1),
notify: make(chan struct{}),
}
go op.wait()
go ops.insert(op)
Expand Down Expand Up @@ -128,7 +128,7 @@ func (op *Operation) wait() {
op.result = result
finished := time.Now()
op.finished = &finished
op.notify <- true
close(op.notify)
}

// WaitFor waits for the specified duration, or until the operation finishes,
Expand All @@ -137,9 +137,6 @@ func (op *Operation) WaitFor(timeout time.Duration) {
select {
case <-time.After(timeout):
case <-op.notify:
// Re-send on this channel in case there are others
// waiting for notification.
op.notify <- true
}
}

Expand Down

0 comments on commit 90cc060

Please sign in to comment.