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 option to use @spawn :samepool for using the same threadpool as the caller #57109

Merged
merged 3 commits into from
Jan 27, 2025

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jan 20, 2025

Adds Threads.@spawn :samepool foo() as shorthand for Threads.@spawn Threads.threadpool() foo() to make it easier to stick within the same threadpool.

ConcurrentUtilities.jl already demonstrates this is desired functionality.

One common use for this is replacing @async with @spawn when there's an interactive thread, given that the main task runs on thread 1, so a bare @spawn will change threadpool to :default, perhaps unexpectedly.

NEWS.md Outdated Show resolved Hide resolved
@IanButterworth
Copy link
Member Author

Maybe :samepool would be clearer?

@IanButterworth IanButterworth changed the title Add option to use @spawn :same for using the same threadpool as the caller Add option to use @spawn :samepool for using the same threadpool as the caller Jan 21, 2025
@IanButterworth
Copy link
Member Author

No objections raised here or #multithreading on slack so I'll go ahead

@IanButterworth IanButterworth merged commit cc3e7b6 into JuliaLang:master Jan 27, 2025
9 checks passed
@IanButterworth IanButterworth deleted the ib/spawn_same branch January 28, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant