Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @threadUnsafe3 #72

Merged
merged 1 commit into from
Nov 13, 2023
Merged

Conversation

armanbilge
Copy link
Member

This annotation is a nice optimization for the common case where a lazy val initializes a pure value and does not need to be synchronized.

Code that is performance sensitive on Scala 2 will still need to avoid lazy val, but for casual code that is already using it at least we can squeeze out some extra performance on Scala 3.

@armanbilge armanbilge requested a review from satorg November 13, 2023 00:43
Comment on lines +36 to +37
test("threadUnsafe3 respected on Scala 3 only") {
Future.sequence(List(Future(foo), Future(foo))).map { _ =>
Copy link
Contributor

Choose a reason for hiding this comment

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

That's clever 👍

Copy link
Contributor

@satorg satorg left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

@armanbilge
Copy link
Member Author

Thanks for the review 🙂

@armanbilge armanbilge merged commit e36ab9d into typelevel:main Nov 13, 2023
@armanbilge armanbilge mentioned this pull request Dec 20, 2023
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