diff --git a/base/stream.jl b/base/stream.jl index 3de61181e978d..b0ef10e21fc7a 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -383,8 +383,23 @@ function isopen(x::Union{LibuvStream, LibuvServer}) return x.status != StatusClosed end +function isclosing(x::Union{LibuvStream, LibuvServer}) + return x.status == StatusClosing +end + +""" + isclosed(x) + +Determine whether a stream has been closed. Return true if the steram has been +closed. In general, `isclosed(x) == !isopen(x)`. +""" +function isclosed(x::Union{LibuvStream, LibuvServer}) + return x.status == StatusClosed +end +isclosed(x) = !isopen(x) + function check_open(x::Union{LibuvStream, LibuvServer}) - if !isopen(x) || x.status == StatusClosing + if !isopen(x) || isclosing(x) throw(IOError("stream is closed or unusable", 0)) end end