Skip to content

Commit

Permalink
doc: add sync/async documentation for file I/O
Browse files Browse the repository at this point in the history
cross-ref JuliaLang#13450
  • Loading branch information
ihnorton committed Jan 22, 2017
1 parent 85543a8 commit 22bceda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function eof end
write(filename::AbstractString, x)
Write the canonical binary representation of a value to the given I/O stream or file.
Returns the number of bytes written into the stream.
Returns the number of bytes written into the stream. (note: file operations are blocking)
You can write multiple values with the same `write` call. i.e. the following are equivalent:
Expand Down Expand Up @@ -351,7 +351,7 @@ read{T}(s::IO, t::Type{T}, d1::Integer, dims::Integer...) =
Read a series of values of type `T` from `stream`, in canonical binary representation.
`dims` is either a tuple or a series of integer arguments specifying the size of the `Array{T}`
to return.
to return. (note: file operations are blocking)
"""
read{T}(s::IO, ::Type{T}, dims::Dims) = read!(s, Array{T}(dims))

Expand Down Expand Up @@ -473,6 +473,7 @@ readchomp(x) = chomp!(readstring(x))
Read at most `nb` bytes from `stream` into `b`, returning the number of bytes read.
The size of `b` will be increased if needed (i.e. if `nb` is greater than `length(b)`
and enough bytes could be read), but it will never be decreased.
(note: file operations are blocking)
"""
function readbytes!(s::IO, b::AbstractArray{UInt8}, nb=length(b))
olb = lb = length(b)
Expand Down
9 changes: 5 additions & 4 deletions doc/src/manual/networking-and-streams.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Networking and Streams

Julia provides a rich interface to deal with streaming I/O objects such as terminals, pipes and
TCP sockets. This interface, though asynchronous at the system level, is presented in a synchronous
manner to the programmer and it is usually unnecessary to think about the underlying asynchronous
operation. This is achieved by making heavy use of Julia cooperative threading ([coroutine](@ref man-tasks))
functionality.
TCP sockets. File I/O (`::IOStream` type), is synchronous at the system level, and thus
process-blocking. All other operations are are asynchronous at the system level, but presented
in a synchronous manner to the programmer; thus it is usually unnecessary to think about the underlying
asynchronous operation. This is achieved by making heavy use of Julia cooperative threading
([coroutine](@ref man-tasks)) functionality.

## Basic Stream I/O

Expand Down

0 comments on commit 22bceda

Please sign in to comment.