Closed KronosTheLate closed 4 months ago
Can you make that a PR? I think all you need is:
if isdefined(Base, :isfull)
import Base: isfull
end
This might qualify as punning. The docstring for Base.isfull
is very specific to Channels---it does not provide a generic definition of isfull
that could also apply to DataStructures.CircularBuffer
.
EDIT: Maybe this comment should have been on PR #896.
I am not familiar with the concept of "punning", but you do have a point. However I feel as if the meaning of isfull
is quite clear from the name, even if it has currently only been deemed usefull for channels in Base.
"Punning" is using the same generic function in two different contexts with two different meanings. "Is full?" seems clear enough, but it would still need a docstring with a generic definition. However, you have to ask yourself if there are ever any circumstances where it makes sense to write a generic function foo
, like this,
function foo(x)
# ...
... isfull(x) ...
# ....
end
that works on both Channel
and DataStructures.CircularBuffer
. (I doubt that there are.) If there are no plausible generic use cases like that, then Base.isfull
and DataStructures.isfull
should probably be separate functions. (In other words, DataStructures should not overload Base.isfull
.)
All that being said, the name isfull(c::Channel)
seems to be in line with the names of the other functions in Base that operate on channels, so it's probably ok to add Base.isfull
. It might have been nice if the Channel functions had been namespaced inside a Channel
module, but that ship sailed a long time ago.
A CircularBuffer (either bounded or unbounded) would be a reasonable implementation choice for the Channel (single or multi-threaded)
Yes. A CircularBuffer is basically the textbook solution to implementing Channels. (I profiled changing the implementation to one back in julia v0.5 days, didn't work out faster) It makes full sense that it would have a very similar API.
Ok, sorry for the noise.
I think technically it is a space savings not a time savings, as you can fit the same sized queue performance in half the memory with a circular buffer implementation
I will close this up, as the issue is (currently being) delt with by https://github.com/JuliaCollections/DataStructures.jl/pull/896.
I just submitted this PR to julia base, which will be breaking for DataStructures.jl if merged.
In order to maintain compatability with both 1.10 and 1.11, I propose we implement something like the following: