File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ Other constructors:
24
24
* `Channel(sz)`: equivalent to `Channel{Any}(sz)`
25
25
26
26
!!! compat "Julia 1.3"
27
- The default constructor `Channel()` was added in Julia 1.3.
27
+ The default constructor `Channel()` and default `sz=0` were added in Julia 1.3.
28
28
"""
29
29
mutable struct Channel{T} <: AbstractChannel{T}
30
30
cond_take:: Threads.Condition # waiting for data to become available
@@ -36,7 +36,7 @@ mutable struct Channel{T} <: AbstractChannel{T}
36
36
data:: Vector{T}
37
37
sz_max:: Int # maximum size of channel
38
38
39
- function Channel {T} (sz:: Integer ) where T
39
+ function Channel {T} (sz:: Integer = 0 ) where T
40
40
if sz < 0
41
41
throw (ArgumentError (" Channel size must be either 0, a positive integer or Inf" ))
42
42
end
Original file line number Diff line number Diff line change 15
15
@testset " various constructors" begin
16
16
c = Channel ()
17
17
@test eltype (c) == Any
18
+ @test c. sz_max == 0
18
19
19
20
c = Channel (1 )
20
21
@test eltype (c) == Any
28
29
@test eltype (c) == Int
29
30
@test_throws MethodError put! (c, " Hello" )
30
31
32
+ c = Channel {Int} ()
33
+ @test eltype (c) == Int
34
+ @test c. sz_max == 0
35
+
31
36
c = Channel {Int} (Inf )
32
37
@test eltype (c) == Int
33
38
pvals = map (i-> put! (c,i), 1 : 10 ^ 6 )
You can’t perform that action at this time.
0 commit comments