Skip to content

Commit 81cbad5

Browse files
committed
Nospecialize ::Channel functions that don't depend on {T}.
- Mark most of the functions on Channels nospecialize when they don't depend on the data type in the Channel, `T`. - Add precompile statement for `Base.close(::Channel, ::Exception)`
1 parent 99bfa7d commit 81cbad5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

base/channels.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ Close a channel. An exception (optionally given by `excp`), is thrown by:
183183
* [`put!`](@ref) on a closed channel.
184184
* [`take!`](@ref) and [`fetch`](@ref) on an empty, closed channel.
185185
"""
186-
close(c::Channel) = close(c, closed_exception()) # nospecialize on default arg seems to confuse makedocs
187-
function close(c::Channel, @nospecialize(excp::Exception))
186+
close(@nospecialize(c::Channel)) = close(c, closed_exception()) # nospecialize on default arg seems to confuse makedocs
187+
@nospecialize function close(c::Channel, excp::Exception)
188188
lock(c)
189189
try
190190
c.excp = excp
@@ -197,7 +197,7 @@ function close(c::Channel, @nospecialize(excp::Exception))
197197
end
198198
nothing
199199
end
200-
isopen(c::Channel) = ((@atomic :monotonic c.state) === :open)
200+
@nospecialize isopen(c::Channel) = ((@atomic :monotonic c.state) === :open)
201201

202202
"""
203203
bind(chnl::Channel, task::Task)

contrib/generate_precompile.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ precompile(Tuple{typeof(isassigned), Core.SimpleVector, Int})
4949
precompile(Tuple{typeof(getindex), Core.SimpleVector, Int})
5050
precompile(Tuple{typeof(Base.Experimental.register_error_hint), Any, Type})
5151
precompile(Tuple{typeof(Base.display_error), Base.ExceptionStack})
52+
precompile(Tuple{typeof(Base.close), Base.Channel, Exception})
5253
precompile(Tuple{Core.kwftype(typeof(Type)), NamedTuple{(:sizehint,), Tuple{Int}}, Type{IOBuffer}})
5354
precompile(Base.CoreLogging.current_logger_for_env, (Base.CoreLogging.LogLevel, String, Module))
5455
precompile(Base.CoreLogging.current_logger_for_env, (Base.CoreLogging.LogLevel, Symbol, Module))

0 commit comments

Comments
 (0)