Skip to content

Commit

Permalink
code prettifying
Browse files Browse the repository at this point in the history
  • Loading branch information
valyala committed Mar 2, 2016
1 parent 15ffe2f commit e4c0cbe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions workerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ func (wp *workerPool) Stop() {
wp.lock.Unlock()
}

const maxIdleWorkerDuration = 10 * time.Second

func (wp *workerPool) clean() {
// Clean least recently used workers if they didn't serve connections
// for more than one second.
// for more than maxIdleWorkerDuration.
wp.lock.Lock()
ready := wp.ready
for len(ready) > 1 && time.Since(ready[0].t) > 10*time.Second {
for len(ready) > 1 && time.Since(ready[0].t) > maxIdleWorkerDuration {
// notify the worker to stop.
ready[0].ch <- nil

Expand Down

0 comments on commit e4c0cbe

Please sign in to comment.