Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

Commit

Permalink
Readme improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fatih committed Jul 20, 2014
1 parent 4f0df5c commit e31bdb1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -37,10 +37,11 @@ p, err := pool.NewChannelPool(5, 30, factory)
// available it will create a new one via the factory function.
conn, err := p.Get()

// do something with conn and put it back to the pool
p.Put(conn)
// do something with conn and put it back to the pool, yes just close the
// connection :)
conn.Close()

// close pool any time you want
// close pool any time you want, this closes all the connections inside a pool
p.Close()

// currently available connections in the pool
Expand Down
8 changes: 0 additions & 8 deletions channel.go
Expand Up @@ -55,10 +55,6 @@ func (c *ChannelPool) getConns() chan net.Conn {
return conns
}

// Get returns a new connection from the pool. Closing the connections puts it
// back to the Pool. Closing it when when the pool is destroyed or full will be
// counted as an error. If there is no new connection available in the pool, a
// new connection will be created via the Factory() method.
func (c *ChannelPool) Get() (conn net.Conn, err error) {
conns := c.getConns()
if conns == nil {
Expand Down Expand Up @@ -107,8 +103,6 @@ func (c *ChannelPool) put(conn net.Conn) error {
}
}

// Close closes the pool and all its connections. After Close() the
// pool is no longer usable.
func (c *ChannelPool) Close() {
c.mu.Lock()
conns := c.conns
Expand All @@ -126,8 +120,6 @@ func (c *ChannelPool) Close() {
}
}

// Cap returns the maximum capacity of the pool
func (c *ChannelPool) Cap() int { return cap(c.getConns()) }

// Len returns the current capacity of the pool.
func (c *ChannelPool) Len() int { return len(c.getConns()) }

0 comments on commit e31bdb1

Please sign in to comment.