diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index e03a684b..aeb535b3 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-03T16:12:32","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-11-03T16:27:01","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/devnotes/index.html b/dev/devnotes/index.html index aeb4d752..ce442a09 100644 --- a/dev/devnotes/index.html +++ b/dev/devnotes/index.html @@ -3,4 +3,4 @@ user <--- |state.buffer1| <--- <stream.codec> <--- |state.buffer2| <--- stream When writing data (`state.mode == :write`): - user ---> |state.buffer1| ---> <stream.codec> ---> |state.buffer2| ---> stream
In the read mode, a user pull out data from state.buffer1
and pre-transcoded data are filled in state.buffer2
. In the write mode, a user will push data into state.buffer1
and transcoded data are filled in state.buffer2
. The default buffer size is 16KiB for each.
State
(defined in src/state.jl) has five fields:
mode
: current stream mode (<:Symbol
)code
: return code of the last codec's method call (<:Symbol
)error
: exception returned by the codec (<:Error
)buffer1
: data buffer that is closer to the user (<:Buffer
)buffer2
: data buffer that is farther to the user (<:Buffer
)The mode
field may be one of the following value:
:idle
: initial and intermediate mode, no buffered data:read
: being ready to read data, data may be buffered:write
: being ready to write data, data may be buffered:stop
: transcoding is stopped, data may be buffered:close
: closed, no buffered data:panic
: an exception has been thrown in codec, data may be buffered but we cannot do anythingNote that mode=:stop
does not mean there is no data available in the stream. This is because transcoded data may be left in the buffer.
The initial mode is :idle
and mode transition happens as shown in the following diagram:
Modes surrounded by a bold circle are a state in which the transcoding stream has released resources by calling finalize(codec)
. The mode transition should happen in the changemode!(stream, newmode)
function in src/stream.jl. Trying an undefined transition will thrown an exception.
A transition happens according to internal or external events of the transcoding stream. The status code and the error object returned by codec methods are internal events, and user's method calls are external events. For example, calling read(stream)
will change the mode from :init
to :read
and then calling close(stream)
will change the mode from :read
to :close
. When data processing fails in the codec, a codec will return :error
and the stream will result in :panic
.
Adjacent transcoding streams may share their buffers. This will reduce memory allocation and eliminate data copy between buffers.
readdata!(input::IO, output::Buffer)
and writedata!(output::IO, input::Buffer)
do the actual work of read/write data from/to the underlying stream. These methods have a special pass for shared buffers.
Noop
codecNoop
(NoopStream
) is a codec that does nothing. It works as a buffering layer on top of the underlying stream. Since NoopStream
does not need to have two distinct buffers, buffer1
and buffer2
in the State
object are shared and some specialized methods are defined for the type. All of these are defined in src/noop.jl.
Settings
This document was generated with Documenter.jl version 1.1.2 on Friday 3 November 2023. Using Julia version 1.9.3.