Skip to content

Commit d106cf1

Browse files
acabarbayeaorabdel
andauthored
Apply suggestions from code review
Co-authored-by: Abdelrahman Abdelraouf <abdelrahman.abdelraouf@arm.com>
1 parent b6c30de commit d106cf1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

utils/parallelisation/cancel_functions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (s *store[T]) Execute(ctx context.Context) (err error) {
141141
return
142142
}
143143

144-
func (s *store[T]) executeConcurrently(ctx context.Context, stopOnFirstError bool) error {
144+
func (s *store[T]) executeInParallel(ctx context.Context, stopOnFirstError bool) error {
145145
g, gCtx := errgroup.WithContext(ctx)
146146
if !stopOnFirstError {
147147
gCtx = ctx
@@ -164,8 +164,8 @@ func (s *store[T]) executeSequentially(ctx context.Context, stopOnFirstError, re
164164
}
165165
if reverse {
166166
for i := len(s.functions) - 1; i >= 0; i-- {
167-
shouldBreak, subErr := s.executeFunction(ctx, s.functions[i])
168-
if shouldBreak {
167+
mustBreak, subErr := s.executeFunction(ctx, s.functions[i])
168+
if mustBreak {
169169
err = subErr
170170
return
171171
}
@@ -195,10 +195,10 @@ func (s *store[T]) executeSequentially(ctx context.Context, stopOnFirstError, re
195195
return
196196
}
197197

198-
func (s *store[T]) executeFunction(ctx context.Context, element T) (shouldBreak bool, err error) {
198+
func (s *store[T]) executeFunction(ctx context.Context, element T) (mustBreak bool, err error) {
199199
err = DetermineContextError(ctx)
200200
if err != nil {
201-
shouldBreak = true
201+
mustBreak = true
202202
return
203203
}
204204
err = s.executeFunc(ctx, element)
@@ -222,7 +222,7 @@ func (s *CancelFunctionStore) Len() int {
222222
return s.store.Len()
223223
}
224224

225-
// NewCancelFunctionsStore creates a store for cancel functions. Whatever the options passed, all cancel functions will be executed.
225+
// NewCancelFunctionsStore creates a store for cancel functions. Whatever the options passed, all cancel functions will be executed and cleared. In other words, options `RetainAfterExecution` and `StopOnFirstError` would be discarded if selected to create the Cancel store
226226
func NewCancelFunctionsStore(options ...StoreOption) *CancelFunctionStore {
227227
return &CancelFunctionStore{
228228
store: *newFunctionStore[context.CancelFunc](func(_ context.Context, cancelFunc context.CancelFunc) error {

0 commit comments

Comments
 (0)