Channel constructor requires an explicit size. Also implements 0-sized channels#18832
Channel constructor requires an explicit size. Also implements 0-sized channels#18832amitmurthy merged 1 commit intomasterfrom
Conversation
7a24ca1 to
6d7b960
Compare
base/channels.jl
Outdated
| put!(c,v,Val{c.sz_max==0}) | ||
| end | ||
|
|
||
| function put!(c::Channel, v, ::Type{Val{false}}) |
There was a problem hiding this comment.
add some comments about what this new Val argument is differentiating?
base/docs/helpdb/Base.jl
Outdated
| a full channel block till an object is removed with `take!`. | ||
|
|
||
| `Channel(0)` constructs a Channel without a backing store. Consequently a `put!` on a | ||
| 0-sized channel will block till another task calls a `take!` on it. And vice-versa. |
base/docs/helpdb/Base.jl
Outdated
| `Channel(0)` constructs a Channel without a backing store. Consequently a `put!` on a | ||
| 0-sized channel will block till another task calls a `take!` on it. And vice-versa. | ||
|
|
||
| `isready` on a 0-sized channel returns true if there are any tasks blocked on a `put!` |
There was a problem hiding this comment.
should be separated with either a period or another line between this and the following statement
d2f385f to
6d5d12e
Compare
|
@tkelman thanks for the feedback. Have pushed a commit that makes the arguments self-explanatory and also updated the docs. |
|
several more cases of "block till" would be better as "block until" I think |
|
@StefanKarpinski your thoughts?
|
|
Yes, in general this is good. A couple of high-level things. It feels like Is all the |
|
In this case, the dispatch on values was mainly for style and readability. Will capture it in the type or replace with if/else. |
|
Updated. |
8b450d9 to
903c464
Compare
|
Deprecated Will squash and merge in a couple of days if there are no more comments. |
|
|
||
| # deprecated empty constructor | ||
| function Channel() | ||
| depwarn(string("The empty constructor Channel() is deprecated. ", |
There was a problem hiding this comment.
why isn't this in deprecated.jl ?
There was a problem hiding this comment.
The Channel{T}() constructor needs to be inside the type definition, while Channel() which is equivalent of Channel{Any}() can be outside. Thus added both in channels.jl itself.
There was a problem hiding this comment.
why can't it be an outer constructor? especially with two different signatures in different places that should be removed, those comments are going to be easy to miss
There was a problem hiding this comment.
How?
Channel() = Channel{Any}(32) is fine.
Channel{T}() = Channel{T}(32) is not callable.
julia> type Foo{T}
foo::T
end
julia> Foo{T}() = Foo{T}(1)
WARNING: static parameter T does not occur in signature for Type at REPL[2]:1.
The method will not be callable.
Foo{T}
Move channel tests into its own file. Implement 0-sized channels.
903c464 to
e23f4e2
Compare
|
@tkelman AV error is unrelated and OSX build is not starting up at all. Should I restart the build? |
As discussed in #17698 (comment), the default channel size of 32 has been removed. The size needs to be specified explicitly.
Channel(Inf)is an unlimited channel, a shorter way of writingChannel(typemax(UInt))Channel tests have been moved into its own file.
Added support for 0-sized channels (as mentioned in #17699). This provides the same behavior as
produce/consumewhich can be deprecated in a separate PR.