Documentation ¶
Overview ¶
Copyright (c) 2015-2018 All rights reserved. 本软件源代码版权归 my.oschina.net/tantexian 所有,允许复制与学习借鉴. Author: tantexian, <tantexian@qq.com> Since: 2017/8/5
Index ¶
Constants ¶
const ( // RDONLY maps the memory read-only. // Attempts to write to the MMap object will result in undefined behavior. RDONLY = 0 // RDWR maps the memory as read-write. Writes to the MMap object will update the // underlying file. RDWR = 1 << iota // COPY maps the memory as copy-on-write. Writes to the MMap object will affect // memory, but the underlying file will remain unchanged. COPY // If EXEC is set, the mapped memory is marked as executable. EXEC )
const ( // If the ANON flag is set, the mapped memory will not be backed by a file. ANON = 1 << iota )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MMap ¶
type MMap []byte
MMap represents a file mapped into memory.
func MapRegion ¶
MapRegion maps part of a file into memory. The offset parameter must be a multiple of the system's page size. If length < 0, the entire file will be mapped. If ANON is set in flags, f is ignored.
func (MMap) Lock ¶
Lock keeps the mapped region in physical memory, ensuring that it will not be swapped out.
func (MMap) Unlock ¶
Unlock reverses the effect of Lock, allowing the mapped region to potentially be swapped out. If m is already unlocked, aan error will result.
func (*MMap) Unmap ¶
Unmap deletes the memory mapped region, flushes any remaining changes, and sets m to nil. Trying to read or write any remaining references to m after Unmap is called will result in undefined behavior. Unmap should only be called on the slice value that was originally returned from a call to Map. Calling Unmap on a derived slice may cause errors.