Skip to content

Commit c039f53

Browse files
committed
Rename shutdown() to closewrite()
This name was suggested in #24526 and * Has a good analogy to close(), so people are likely to be able to guess what it means. * Is more specific to IO (conversely, it's easy to imagine shutdown() being wanted for any number of things unrelated to closing the write side of an IO stream).
1 parent 7a784de commit c039f53

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Standard library changes
4949
overflow in most cases. The new function `checked_length` is now available, which will try to use checked
5050
arithmetic to error if the result may be wrapping. Or use a package such as SaferIntegers.jl when
5151
constructing the range. ([#40382])
52-
* TCP socket objects now expose `shutdown` functionality and support half-open mode usage ([#40783]).
52+
* TCP socket objects now expose `closewrite` functionality and support half-open mode usage ([#40783]).
5353

5454
#### InteractiveUtils
5555
* A new macro `@time_imports` for reporting any time spent importing packages and their dependencies ([#41612])

base/exports.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ export
803803

804804
# I/O and events
805805
close,
806-
shutdown,
806+
closewrite,
807807
countlines,
808808
eachline,
809809
readeach,

base/io.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Close an I/O stream. Performs a [`flush`](@ref) first.
6262
function close end
6363

6464
"""
65-
shutdown(stream)
65+
closewrite(stream)
6666
6767
Shutdown the write half of a full-duplex I/O stream. Performs a [`flush`](@ref)
6868
first. Notify the other end that no more data will be written to the underlying
@@ -76,12 +76,12 @@ julia> write(io, "request");
7676
7777
julia> # calling `read(io)` here would block forever
7878
79-
julia> shutdown(io);
79+
julia> closewrite(io);
8080
8181
julia> read(io, String)
8282
"request"
8383
"""
84-
function shutdown end
84+
function closewrite end
8585

8686
"""
8787
flush(stream)
@@ -410,7 +410,7 @@ end
410410
function pipe_reader end
411411
function pipe_writer end
412412

413-
for f in (:flush, :shutdown, :iswritable)
413+
for f in (:flush, :closewrite, :iswritable)
414414
@eval $(f)(io::AbstractPipe) = $(f)(pipe_writer(io)::IO)
415415
end
416416
write(io::AbstractPipe, byte::UInt8) = write(pipe_writer(io)::IO, byte)

base/iobuffer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ end
334334

335335
eof(io::GenericIOBuffer) = (io.ptr-1 == io.size)
336336

337-
function shutdown(io::GenericIOBuffer)
337+
function closewrite(io::GenericIOBuffer)
338338
io.writable = false
339-
# OR throw(_UVError("shutdown", UV_ENOTSOCK))
339+
# OR throw(_UVError("closewrite", UV_ENOTSOCK))
340340
nothing
341341
end
342342

base/process.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ function setup_stdio(stdio::Union{IOBuffer, BufferStream}, child_readable::Bool)
275275
@warn "Process error" exception=(ex, catch_backtrace())
276276
finally
277277
close(parent)
278-
child_readable || shutdown(stdio)
278+
child_readable || closewrite(stdio)
279279
end
280280
end
281281
catch ex

base/stream.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function wait_readnb(x::LibuvStream, nb::Int)
433433
nothing
434434
end
435435

436-
function shutdown(s::LibuvStream)
436+
function closewrite(s::LibuvStream)
437437
iolock_begin()
438438
check_open(s)
439439
req = Libc.malloc(_sizeof_uv_shutdown)
@@ -1476,7 +1476,7 @@ end
14761476

14771477
isopen(s::BufferStream) = s.status != StatusClosed
14781478

1479-
shutdown(s::BufferStream) = close(s)
1479+
closewrite(s::BufferStream) = close(s)
14801480

14811481
function close(s::BufferStream)
14821482
lock(s.cond) do

doc/src/base/io-network.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Base.take!(::Base.GenericIOBuffer)
1313
Base.fdio
1414
Base.flush
1515
Base.close
16-
Base.shutdown
16+
Base.closewrite
1717
Base.write
1818
Base.read
1919
Base.read!

stdlib/Sockets/test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ end
566566
end
567567
let s = Sockets.connect(addr)
568568
@test iswritable(s)
569-
shutdown(s)
569+
closewrite(s)
570570
@test !iswritable(s)
571571
close(s)
572572
end
@@ -578,7 +578,7 @@ end
578578
end
579579
@test iswritable(s)
580580
write(s, "hello world\n")
581-
shutdown(s)
581+
closewrite(s)
582582
@test !iswritable(s)
583583
@test isreadable(s)
584584
@test read(s, String) == "hello world\n"

0 commit comments

Comments
 (0)