manpagez: man pages & more
info bigloo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2.2 mmap

The mmap function asks to map a file into memory. This memory area can be randomly accessed as a string. In general using mmap improves performance in comparison with equivalent code using regular ports.

bigloo procedure: mmap? obj

Returns #t if and only if obj has been produced by open-mmap. Otherwise, it returns #f.

bigloo procedure: open-mmap path [mode]

Maps a file path into memory. The optional argument mode specifies how the file is open. The argument can be:

  • read: #t The memory can be read
  • read: #f The memory cannot be read
  • write: #t The memory can be written
  • write: #f The memory is read-only.
bigloo procedure: string->mmap string [mode]

Wrap a Bigloo string into a mmap object.

bigloo procedure: close-mmap mm

Closes the memory mapped. Returns #t on success, #f otherwise.

bigloo procedure: mmap-length mm

Returns the length, an exact integer, of the memory mapped.

bigloo procedure: mmap-read-position mm
bigloo procedure: mmap-read-position-set! mm offset
bigloo procedure: mmap-write-position mm
bigloo procedure: mmap-write-position-set! mm offset

Returns and sets the read and write position of a memory mapped memory. The result and the argument are exact integers.

bigloo procedure: mmap-ref mm offset

Reads the character in mm at offset, an exact long (::elong). This function sets the read position to offset + 1.

bigloo procedure: mmap-set! mm offset char

Writes the character char in mm at offset, an exact long (::elong). This function sets the write position to offset + 1.

bigloo procedure: mmap-substring mm start end

Returns a newly allocated string made of the characters read from mm starting at position start and ending at position end - 1. If the values start and end are not ranged in [0...(mmap-length mm)], an error is signaled. The function mmap-substring sets the read position to end.

bigloo procedure: mmap-substring-set! mm start str

Writes the string str to mm at position start. If the values start and start + (string-length str) are not ranged in [0...(mmap-length mm)[, an error is signaled. The function mmap-substring sets the write position to start + (string-length str).

bigloo procedure: mmap-get-char mm
bigloo procedure: mmap-put-char! mm c
bigloo procedure: mmap-get-string mm len
bigloo procedure: mmap-put-string! mm str

These functions get (resp. put) character and strings into a memory mapped area. They increment the read (resp. write) position. An error is signaled if the characters read (resp. writen) outbound the length of the memory mapped.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October 23, 2011 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.