Skip to content
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

perf(mux) use RWMutex #218

Merged
merged 1 commit into from
Oct 28, 2014
Merged
Changes from all commits
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
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