-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Base.n_avail(::Channel)
public
#31520
Comments
Before making anything public, can we think about consistent naming? We export |
... or it could be |
That's not a bad thought. Does it make sense to expose a container-like API for channels? |
If we want to call it |
isempty(ch) = length(ch) == 0 Using function files_upload(auth::Authorization,
path::String,
content_channel::Union{AbstractChannel{Vector{UInt8}},
AbstractVector{Vector{UInt8}}}
)::FileMetadata You might need a few other functions, e.g. popfirst!(ch) = take!(ch)
push!(ch) = put!(ch) However, I wouldn't compare |
This is not a Thinking of it another way, the purpose of channels is basically synchronization. If you use them like an array, then you lose that and you're back to your code being as racy as if you just used an array. |
The point is the generic function |
That's true if there's multiple consumers, but actually it's sometimes valid (and not race-y) to use these operations, for example if you only plan to have one consumer (and any number of producers to synchronize with). Sort of an odd asymmetry to consider, but it's theoretically meaningful to call it |
I think even then it's not a length, since it doesn't tell you how many values you will get. |
Related: #12781 |
The function
Base.n_avail(::Channel)
returns how many items are currently queued in a channel. It is used internally to implementisready(::Channel)
.It would be convenient if
n_avail
was also public and documented. I would use it e.g. to output progress information.The text was updated successfully, but these errors were encountered: