A stream class giving access to stream buffers.
stream
lob-stream
string-stream
socket-stream
:direction |
One of :input , :output or :io . This argument is required. |
:element-type | |
:static-buffers |
The class buffered-stream
provides default methods for the majority of the functions in the User Defined Streams protocol. The default methods implement buffered I/O, requiring the user to define only the methods stream-read-buffer, stream-write-buffer and stream-element-type for each subclass of buffered-stream
. You are at liberty to redefine other methods in subclasses as long as they obey the rules outlined here. For example it is usually desirable to implement methods on stream-listen, stream-check-eof-no-hang and close as well.
The initargs are handled by the method (method initialize-instance :after (buffered-stream))
as follows:
Input and/or output buffers are created based on the value direction. There is no default value, and you must supply a value.
element-type determines the stream-element-type of the stream. The default is base-char. For binary streams, use base-char.
static-buffers controls whether the buffers for input and output are allocated as static objects (see 11.3.2.1 Allocation of static objects). The default is nil
, which causes these buffers are allocated as ordinary Lisp objects that may be moved by the garbage collector. If static-buffers is non-nil, then the buffers are made as static Lisp objects. Most importantly, that allows you to pass the buffers directly to foreign functions, and that is typically the reason for supplying static-buffers. Note: The static buffers are allocated from a resource, and are released when the stream is closed, so foreign code should not access them after that.
All the methods in the User Defined Streams protocol are defined for buffered-stream
as follows:
:around
methods on stream-listen and close which handle the buffer.:direction
initarg.See the extended example in:
(example-edit-file "streams/buffered-stream")
close
stream-flush-buffer
stream-fill-buffer
stream-listen
stream-read-buffer
stream-write-buffer
with-stream-input-buffer
LispWorks® User Guide and Reference Manual - 18 Feb 2025 15:32:45