Commit 36aa391b authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add Drop method to splice pool.

parent ba9f7973
...@@ -29,10 +29,16 @@ func Used() int { ...@@ -29,10 +29,16 @@ func Used() int {
return splicePool.used() return splicePool.used()
} }
// Return pipe pair to pool
func Done(p *Pair) { func Done(p *Pair) {
splicePool.done(p) splicePool.done(p)
} }
// Closes and discards pipe pair.
func Drop(p *Pair) {
splicePool.drop(p)
}
func newSplicePairPool() *pairPool { func newSplicePairPool() *pairPool {
return &pairPool{} return &pairPool{}
} }
...@@ -61,6 +67,13 @@ func (me *pairPool) total() int { ...@@ -61,6 +67,13 @@ func (me *pairPool) total() int {
return n return n
} }
func (me *pairPool) drop(p *Pair) {
p.Close()
me.Lock()
me.usedCount--
me.Unlock()
}
func (me *pairPool) get() (p *Pair, err error) { func (me *pairPool) get() (p *Pair, err error) {
me.Lock() me.Lock()
defer me.Unlock() defer me.Unlock()
......
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