| Copyright | (c) The University of Glasgow 2008 |
|---|---|
| License | see libraries/base/LICENSE |
| Maintainer | cvs-ghc@haskell.org |
| Stability | internal |
| Portability | non-portable (GHC Extensions) |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
GHC.IO.Buffer
Contents
Description
Buffers used in the IO system
A mutable array of bytes that can be passed to foreign functions.
The buffer is represented by a record, where the record contains the raw buffer and the start/end points of the filled portion. The buffer contents itself is mutable, but the rest of the record is immutable. This is a slightly odd mix, but it turns out to be quite practical: by making all the buffer metadata immutable, we can have operations on buffer metadata outside of the IO monad.
The "live" elements of the buffer are those between thebufL andbufR offsets. In an empty buffer,bufL is equal tobufR, but they might not be zero: for example, the buffer might correspond to a memory-mapped file and in which casebufL will point to the next location to be written, which is not necessarily the beginning of the file.
Constructors
| ReadBuffer | |
| WriteBuffer |
| EqBufferStateSource# | Since: 4.2.0.0 |
Instance detailsDefined inGHC.IO.Buffer | |
typeCharBufElem =CharSource#
newByteBuffer ::Int ->BufferState ->IO (BufferWord8)Source#
emptyBuffer ::RawBuffer e ->Int ->BufferState ->Buffer eSource#
slideContents ::BufferWord8 ->IO (BufferWord8)Source#
slides the contents of the buffer to the beginning
isEmptyBuffer ::Buffer e ->BoolSource#
isFullBuffer ::Buffer e ->BoolSource#
isWriteBuffer ::Buffer e ->BoolSource#
bufferElems ::Buffer e ->IntSource#
bufferAvailable ::Buffer e ->IntSource#
summaryBuffer ::Buffer a ->StringSource#
checkBuffer ::Buffer a ->IO ()Source#
typeRawBuffer e =ForeignPtr eSource#
readCharBuf ::RawCharBuffer ->Int ->IO (Char,Int)Source#
writeCharBuf ::RawCharBuffer ->Int ->Char ->IOIntSource#
readCharBufPtr ::PtrCharBufElem ->Int ->IO (Char,Int)Source#
writeCharBufPtr ::PtrCharBufElem ->Int ->Char ->IOIntSource#
Produced byHaddock version 2.20.0