packer/rpc: clean up unnecessary functions

This commit is contained in:
Mitchell Hashimoto 2013-12-12 13:21:42 -08:00
parent b93a9c0a49
commit b1f07dcbe0
1 changed files with 2 additions and 10 deletions

View File

@ -418,14 +418,6 @@ func (s *Stream) remoteClose() {
s.writeCh <- nil s.writeCh <- nil
} }
func (s *Stream) registerStateListener(ch chan<- streamState) {
s.stateChange[ch] = struct{}{}
}
func (s *Stream) deregisterStateListener(ch chan<- streamState) {
delete(s.stateChange, ch)
}
func (s *Stream) setState(state streamState) { func (s *Stream) setState(state streamState) {
log.Printf("[TRACE] Stream %d went to state %d", s.id, state) log.Printf("[TRACE] Stream %d went to state %d", s.id, state)
s.state = state s.state = state
@ -441,12 +433,12 @@ func (s *Stream) setState(state streamState) {
func (s *Stream) waitState(target streamState) error { func (s *Stream) waitState(target streamState) error {
// Register a state change listener to wait for changes // Register a state change listener to wait for changes
stateCh := make(chan streamState, 10) stateCh := make(chan streamState, 10)
s.registerStateListener(stateCh) s.stateChange[stateCh] = struct{}{}
s.mu.Unlock() s.mu.Unlock()
defer func() { defer func() {
s.mu.Lock() s.mu.Lock()
s.deregisterStateListener(stateCh) delete(s.stateChange, stateCh)
}() }()
state := <-stateCh state := <-stateCh