From a946ad74a060462408c1b36938a624d6c0e66f30 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 22 Feb 2024 01:00:17 -0500 Subject: [PATCH 1/2] Create isclosing and isclosed methods --- base/stream.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/base/stream.jl b/base/stream.jl index 3de61181e978d..9216fc86927c9 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -383,8 +383,16 @@ function isopen(x::Union{LibuvStream, LibuvServer}) return x.status != StatusClosed end +function isclosing(x::Union{LibuvStream, LibuvServer}) + return x.status == StatusClosing +end + +function isclosed(x::Union{LibuvStream, LibuvServer}) + return x.status == StatusClosed +end + 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 From b04dc474e3fccce1b7a68306d826d32e69250c36 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 22 Feb 2024 02:19:42 -0500 Subject: [PATCH 2/2] Document `Based.isclosed`. --- base/stream.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base/stream.jl b/base/stream.jl index 9216fc86927c9..b0ef10e21fc7a 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -387,9 +387,16 @@ 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) || isclosing(x)