github.com/flower-corp/rosedb@v1.1.2-0.20230117132829-21dc4f7b319a/mmap/mmap.go (about)

     1  package mmap
     2  
     3  import (
     4  	"os"
     5  )
     6  
     7  // Mmap uses the mmap system call to memory-map a file. If writable is true,
     8  // memory protection of the pages is set so that they may be written to as well.
     9  func Mmap(fd *os.File, writable bool, size int64) ([]byte, error) {
    10  	return mmap(fd, writable, size)
    11  }
    12  
    13  // Munmap unmaps a previously mapped slice.
    14  func Munmap(b []byte) error {
    15  	return munmap(b)
    16  }
    17  
    18  // Madvise uses the madvise system call to give advise about the use of memory
    19  // when using a slice that is memory-mapped to a file. Set the readahead flag to
    20  // false if page references are expected in random order.
    21  func Madvise(b []byte, readahead bool) error {
    22  	return madvise(b, readahead)
    23  }
    24  
    25  // Msync would call sync on the mmapped data.
    26  func Msync(b []byte) error {
    27  	return msync(b)
    28  }