Skip to content

Commit

Permalink
deprecated Channel() instead of throwing an error
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmurthy committed Oct 18, 2016
1 parent 2e854b4 commit 903c464
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions base/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ type Channel{T} <: AbstractChannel
end
new(Condition(), Condition(), :open, Array{T}(0), sz, Array{Condition}(0))
end

# deprecated empty constructor
function Channel()
depwarn(string("The empty constructor Channel() is deprecated. ",
"The channel size needs to be specified explictly. ",
"Defaulting to Channel{$T}(32)."), :Channel)
Channel(32)
end
end

Channel(sz) = Channel{Any}(sz)

# deprecated empty constructor
Channel() = Channel{Any}()

closed_exception() = InvalidStateException("Channel is closed.", :closed)

isbuffered(c::Channel) = c.sz_max==0 ? false : true
Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1023,4 +1023,7 @@ end))

@deprecate is (===)

# NOTE: Deprecation of Channel{T}() is implemented in channels.jl.
# To be removed from there when 0.6 deprecations are removed.

# End deprecations scheduled for 0.6
4 changes: 3 additions & 1 deletion test/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ pvals = map(i->put!(c,i), 1:10^6)
tvals = Int[take!(c) for i in 1:10^6]
@test pvals == tvals

@test_throws MethodError Channel()
# Uncomment line below once deprecation support has been removed.
# @test_throws MethodError Channel()

@test_throws ArgumentError Channel(-1)
@test_throws InexactError Channel(1.5)

Expand Down

0 comments on commit 903c464

Please sign in to comment.