Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kyri-petrou
Copy link
Contributor

No description provided.

Comment on lines +6317 to +6318
else if (parallelism >= size)
foreachParUnboundedDiscard(as, size)(f)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be a distinct branch? Wouldn't val nWorkers = parallelism.min(size) take care of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more optimal because in this branch we don't have to go through polling via the queue. But you're right this makes val nWorkers = parallelism.min(size) obsolete, we can simply use parallelism with this new implementation

* the result in a new `Collection[B]` using the specified execution strategy.
*/
final def foreachExec[R, E, A, B, Collection[+Element] <: Iterable[Element]](as: Collection[A])(
def foreachExec[R, E, A, B, Collection[+Element] <: Iterable[Element]](
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume final was unnecessary in the object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap 👍

@kyri-petrou kyri-petrou merged commit 25cd6fa into zio:series/2.x Apr 21, 2025
18 checks passed
@kyri-petrou kyri-petrou deleted the optimize-foreachExec branch April 21, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants