-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
threadpool=:default
parameter to Channel
constructor
Without this, the task created by a `Channel` will run in the threadpool of the creating task; in the REPL, this could be the interactive threadpool. With this, the `:default` threadpool is used instead, and that behavior can be overridden.
- Loading branch information
Showing
3 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
using Test | ||
using Base.Threads | ||
|
||
@testset "Task threadpools" begin | ||
c = Channel{Symbol}() do c; put!(c, threadpool(current_task())); end | ||
@test take!(c) === threadpool(current_task()) | ||
c = Channel{Symbol}(spawn = true) do c; put!(c, threadpool(current_task())); end | ||
@test take!(c) === :default | ||
c = Channel{Symbol}(threadpool = :interactive) do c; put!(c, threadpool(current_task())); end | ||
@test take!(c) === :interactive | ||
@test_throws ArgumentError Channel{Symbol}(threadpool = :foo) do c; put!(c, :foo); end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters