Skip to content

Commit 7c7871b

Browse files
committed
feat: rename ParallelComplete to ParallelCompleted.
1 parent 2a7c012 commit 7c7871b

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

parallel.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,36 @@ func runTaskInParallel(
107107
}
108108
}
109109

110-
// ParallelComplete runs the functions asynchronously with the specified concurrency limitation. It
111-
// returns an error array and a boolean value to indicate whether any function panics or returns an
112-
// error, and you can get the error details from the error array by the indices of the functions in
113-
// the parameter list. It will return until all of the functions are finished.
110+
// ParallelCompleted runs the functions asynchronously with the specified concurrency limitation.
111+
// It returns an error array and a boolean value to indicate whether any function panics or returns
112+
// an error, and you can get the error details from the error array by the indices of the functions
113+
// in the parameter list. It will return until all of the functions are finished.
114114
//
115115
// The number of concurrency must be greater than or equal to 0, and it means no concurrency
116116
// limitation if the number is 0.
117-
func ParallelComplete(concurrency int, funcs ...AsyncFn) ([]error, bool) {
118-
return parallelComplete(context.Background(), concurrency, funcs...)
117+
func ParallelCompleted(concurrency int, funcs ...AsyncFn) ([]error, bool) {
118+
return parallelCompleted(context.Background(), concurrency, funcs...)
119119
}
120120

121-
// ParallelCompleteWithContext runs the functions asynchronously with the specified concurrency
121+
// ParallelCompletedWithContext runs the functions asynchronously with the specified concurrency
122122
// limitation and the context. It returns an error array and a boolean value to indicate whether
123123
// any function panics or returns an error, and you can get the error details from the error array
124124
// by the indices of the functions in the parameter list. It will return until all of the functions
125125
// are finished.
126126
//
127127
// The number of concurrency must be greater than or equal to 0, and it means no concurrency
128128
// limitation if the number is 0.
129-
func ParallelCompleteWithContext(
129+
func ParallelCompletedWithContext(
130130
ctx context.Context,
131131
concurrency int,
132132
funcs ...AsyncFn,
133133
) ([]error, bool) {
134-
return parallelComplete(ctx, concurrency, funcs...)
134+
return parallelCompleted(ctx, concurrency, funcs...)
135135
}
136136

137-
// parallelComplete runs the functions asynchronously with the specified concurrency until all of
137+
// parallelCompleted runs the functions asynchronously with the specified concurrency until all of
138138
// the functions are finished.
139-
func parallelComplete(parent context.Context, concurrency int, funcs ...AsyncFn) ([]error, bool) {
139+
func parallelCompleted(parent context.Context, concurrency int, funcs ...AsyncFn) ([]error, bool) {
140140
// the number of concurrency should be 0 (no limitation) or greater than 0.
141141
if concurrency < 0 {
142142
panic(ErrInvalidConcurrency)

parallel_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,19 @@ func TestParallelWithTimedOutContext(t *testing.T) {
138138
a.EqualNow(finishedNum, 2)
139139
}
140140

141-
func TestParallelComplete(t *testing.T) {
141+
func TestParallelCompleted(t *testing.T) {
142142
a := assert.New(t)
143143

144-
errs, hasError := ParallelComplete(0)
144+
errs, hasError := ParallelCompleted(0)
145145
a.NotTrueNow(hasError)
146146
a.EqualNow(errs, []error{})
147147

148148
a.PanicNow(func() {
149-
ParallelComplete(-1)
149+
ParallelCompleted(-1)
150150
})
151151
}
152152

153-
func TestParallelCompleteWithoutConcurrencyLimit(t *testing.T) {
153+
func TestParallelCompletedWithoutConcurrencyLimit(t *testing.T) {
154154
a := assert.New(t)
155155

156156
funcs := make([]AsyncFn, 0, 5)
@@ -162,14 +162,14 @@ func TestParallelCompleteWithoutConcurrencyLimit(t *testing.T) {
162162
}
163163

164164
start := time.Now()
165-
errs, hasError := ParallelComplete(0, funcs...)
165+
errs, hasError := ParallelCompleted(0, funcs...)
166166
dur := time.Since(start)
167167
a.NotTrueNow(hasError)
168168
a.EqualNow(errs, []error{nil, nil, nil, nil, nil})
169169
a.TrueNow(dur-100*time.Millisecond < 30*time.Millisecond) // allow 30ms deviation
170170
}
171171

172-
func TestParallelCompleteWithConcurrencyLimit(t *testing.T) {
172+
func TestParallelCompletedWithConcurrencyLimit(t *testing.T) {
173173
a := assert.New(t)
174174

175175
funcs := make([]AsyncFn, 0, 5)
@@ -181,14 +181,14 @@ func TestParallelCompleteWithConcurrencyLimit(t *testing.T) {
181181
}
182182

183183
start := time.Now()
184-
errs, hasError := ParallelComplete(2, funcs...)
184+
errs, hasError := ParallelCompleted(2, funcs...)
185185
dur := time.Since(start)
186186
a.NotTrueNow(hasError)
187187
a.EqualNow(errs, []error{nil, nil, nil, nil, nil})
188188
a.TrueNow(dur-300*time.Millisecond < 30*time.Millisecond) // allow 30ms deviation
189189
}
190190

191-
func TestParallelCompleteWithFailedTask(t *testing.T) {
191+
func TestParallelCompletedWithFailedTask(t *testing.T) {
192192
a := assert.New(t)
193193

194194
expectedErr := errors.New("expected error")
@@ -207,12 +207,12 @@ func TestParallelCompleteWithFailedTask(t *testing.T) {
207207
})
208208
}
209209

210-
errs, hasError := ParallelComplete(0, funcs...)
210+
errs, hasError := ParallelCompleted(0, funcs...)
211211
a.TrueNow(hasError)
212212
a.EqualNow(errs, []error{nil, nil, expectedErr, nil, nil})
213213
}
214214

215-
func TestParallelCompleteWithContext(t *testing.T) {
215+
func TestParallelCompletedWithContext(t *testing.T) {
216216
a := assert.New(t)
217217

218218
funcs := make([]AsyncFn, 0, 5)
@@ -226,7 +226,7 @@ func TestParallelCompleteWithContext(t *testing.T) {
226226
})
227227
}
228228

229-
errs, hasError := ParallelCompleteWithContext(context.Background(), 2, funcs...)
229+
errs, hasError := ParallelCompletedWithContext(context.Background(), 2, funcs...)
230230
a.NotTrueNow(hasError)
231231
a.EqualNow(errs, []error{nil, nil, nil, nil, nil})
232232

@@ -239,7 +239,7 @@ func TestParallelCompleteWithContext(t *testing.T) {
239239
a.EqualNow(finishedNum, 5)
240240
}
241241

242-
func TestParallelCompleteWithTimedOutContext(t *testing.T) {
242+
func TestParallelCompletedWithTimedOutContext(t *testing.T) {
243243
a := assert.New(t)
244244

245245
timeoutErr := errors.New("timed out")
@@ -264,7 +264,7 @@ func TestParallelCompleteWithTimedOutContext(t *testing.T) {
264264
ctx, canFunc := context.WithTimeout(context.Background(), 150*time.Millisecond)
265265
defer canFunc()
266266

267-
errs, hasError := ParallelCompleteWithContext(ctx, 2, funcs...)
267+
errs, hasError := ParallelCompletedWithContext(ctx, 2, funcs...)
268268
a.TrueNow(hasError)
269269

270270
numErrors := 0

0 commit comments

Comments
 (0)