Skip to content

Commit

Permalink
rename n_avail(Channel) to navailable()
Browse files Browse the repository at this point in the history
+ docs & export
  • Loading branch information
alyst committed Sep 11, 2015
1 parent 53f2fa6 commit 3a7ce16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions base/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,18 @@ The maximal number of elements the channel can store.
"""
capacity(c::Channel) = c.sz_max

function n_avail(c::Channel)
"""
The number of elements currently in the channel.
"""
function navailable(c::Channel)
if c.put_pos >= c.take_pos
return c.put_pos - c.take_pos
else
return c.szp1 - c.take_pos + c.put_pos
end
end

show(io::IO, c::Channel) = print(io, "$(typeof(c))(capacity:$(capacity(c)), sz_curr:$(n_avail(c)))")
show(io::IO, c::Channel) = print(io, "$(typeof(c))(capacity:$(capacity(c)), navailable:$(navailable(c)))")

start{T}(c::Channel{T}) = Ref{Nullable{T}}()
function done(c::Channel, state::Ref)
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ export
launch,
manage,
myid,
navailable,
nprocs,
nworkers,
pmap,
Expand Down

0 comments on commit 3a7ce16

Please sign in to comment.