Commit ae405425 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

splice: use Go style naming for pairPool.

parent 6aa09dea
...@@ -47,46 +47,46 @@ func newSplicePairPool() *pairPool { ...@@ -47,46 +47,46 @@ func newSplicePairPool() *pairPool {
return &pairPool{} return &pairPool{}
} }
func (me *pairPool) clear() { func (pp *pairPool) clear() {
me.Lock() pp.Lock()
for _, p := range me.unused { for _, p := range pp.unused {
p.Close() p.Close()
} }
me.unused = me.unused[:0] pp.unused = pp.unused[:0]
me.Unlock() pp.Unlock()
} }
func (me *pairPool) used() (n int) { func (pp *pairPool) used() (n int) {
me.Lock() pp.Lock()
n = me.usedCount n = pp.usedCount
me.Unlock() pp.Unlock()
return n return n
} }
func (me *pairPool) total() int { func (pp *pairPool) total() int {
me.Lock() pp.Lock()
n := me.usedCount + len(me.unused) n := pp.usedCount + len(pp.unused)
me.Unlock() pp.Unlock()
return n return n
} }
func (me *pairPool) drop(p *Pair) { func (pp *pairPool) drop(p *Pair) {
p.Close() p.Close()
me.Lock() pp.Lock()
me.usedCount-- pp.usedCount--
me.Unlock() pp.Unlock()
} }
func (me *pairPool) get() (p *Pair, err error) { func (pp *pairPool) get() (p *Pair, err error) {
me.Lock() pp.Lock()
defer me.Unlock() defer pp.Unlock()
me.usedCount++ pp.usedCount++
l := len(me.unused) l := len(pp.unused)
if l > 0 { if l > 0 {
p := me.unused[l-1] p := pp.unused[l-1]
me.unused = me.unused[:l-1] pp.unused = pp.unused[:l-1]
return p, nil return p, nil
} }
...@@ -110,13 +110,13 @@ func discardAll(fd int) { ...@@ -110,13 +110,13 @@ func discardAll(fd int) {
} }
} }
func (me *pairPool) done(p *Pair) { func (pp *pairPool) done(p *Pair) {
discardAll(p.r) discardAll(p.r)
me.Lock() pp.Lock()
me.usedCount-- pp.usedCount--
me.unused = append(me.unused, p) pp.unused = append(pp.unused, p)
me.Unlock() pp.Unlock()
} }
func init() { func init() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment