Skip to content

Commit

Permalink
perf(mux) use RWMutex
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Tiger Chow committed Oct 28, 2014
1 parent 0197fe6 commit ed0556b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/mux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type Muxer struct {
// Protocols are the multiplexed services.
Protocols ProtocolMap

bwiLock sync.Mutex
bwiLock sync.RWMutex
bwIn uint64

bwoLock sync.Mutex
bwoLock sync.RWMutex
bwOut uint64

*msg.Pipe
Expand Down Expand Up @@ -76,13 +76,13 @@ func (m *Muxer) GetPipe() *msg.Pipe {

// GetBandwidthTotals return the in/out bandwidth measured over this muxer.
func (m *Muxer) GetBandwidthTotals() (in uint64, out uint64) {
m.bwiLock.Lock()
m.bwiLock.RLock()
in = m.bwIn
m.bwiLock.Unlock()
m.bwiLock.RUnlock()

m.bwoLock.Lock()
m.bwoLock.RLock()
out = m.bwOut
m.bwoLock.Unlock()
m.bwoLock.RUnlock()
return
}

Expand Down

0 comments on commit ed0556b

Please sign in to comment.