Skip to content

Commit

Permalink
Removed the need for the sync/atomic package
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterclaerhout committed Jul 29, 2019
1 parent 05db3b1 commit bbe3a3a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions waitgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package waitgroup

import (
"sync"
"sync/atomic"
// "sync/atomic"
)

// WaitGroup implements a simple goruntine pool.
Expand Down Expand Up @@ -31,17 +31,17 @@ func (wg *WaitGroup) BlockAdd() {
if wg.size > 0 {
wg.pool <- 1
}
// atomic.AddInt64(&wg.waitCount, 1)
wg.waitGroup.Add(1)
atomic.AddInt64(&wg.waitCount, 1)
}

// Done pops ‘one’ out the group.
func (wg *WaitGroup) Done() {
if wg.size > 0 {
<-wg.pool
}
// atomic.AddInt64(&wg.waitCount, -1)
wg.waitGroup.Done()
atomic.AddInt64(&wg.waitCount, -1)
}

// Wait waiting the group empty
Expand All @@ -51,5 +51,5 @@ func (wg *WaitGroup) Wait() {

// PendingCount returns the number of pending operations
func (wg *WaitGroup) PendingCount() int64 {
return wg.waitCount
return int64(len(wg.pool))
}

0 comments on commit bbe3a3a

Please sign in to comment.