Skip to content

Commit

Permalink
rename NewPool to New
Browse files Browse the repository at this point in the history
  • Loading branch information
icefed committed Apr 11, 2024
1 parent 9f011f6 commit ba1c0ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const (
signalAddTask
)

// NewPool create a routine pool with options.
func NewPool(opts ...Option) *Pool {
// New create a routine pool with options.
func New(opts ...Option) *Pool {
o := defaultOptions()
for _, option := range opts {
option.apply(o)
Expand Down
10 changes: 5 additions & 5 deletions pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (c *Count) Do() {
}

func TestPoolStopAndStart(t *testing.T) {
p := NewPool()
p := New()
p.StartN(1)
// already started
p.Start()
Expand All @@ -36,7 +36,7 @@ func TestPoolStopAndStart(t *testing.T) {
}

func TestPoolWaite(t *testing.T) {
p := NewPool(WithMaxWorkers(10))
p := New(WithMaxWorkers(10))
p.Start()
c := &Count{}
for i := 0; i < 100; i++ {
Expand All @@ -53,7 +53,7 @@ func TestPoolWaite(t *testing.T) {
}

func TestPoolWaiteTimeout(t *testing.T) {
p := NewPool(WithMaxWorkers(10))
p := New(WithMaxWorkers(10))
// not started
p.WaitTimeout(time.Second * 3)

Expand Down Expand Up @@ -82,7 +82,7 @@ func (e *Err) Do() {
}

func TestPoolPanic(t *testing.T) {
p := NewPool(WithMaxWorkers(10))
p := New(WithMaxWorkers(10))
p.Start()
// nil task should be ignored
p.AddTask(nil)
Expand All @@ -100,7 +100,7 @@ func TestPoolPanic(t *testing.T) {
}

func TestPoolPanicAfterStop(t *testing.T) {
p := NewPool()
p := New()
p.StartN(2)
p.AddTask(func() {})
p.AddTask(func() {
Expand Down

0 comments on commit ba1c0ca

Please sign in to comment.