コード例 #1
0
ファイル: buffer.go プロジェクト: postfix/buffer
func (b *Buffer) dontNeed(i, j uint64) error {
	// Since i is rounded up to the nearest multiple of
	// pageSize before the call, i > j is not an error.
	if i > j {
		return nil
	}
	return syscall.Madvise(b.data[i:j], syscall.MADV_DONTNEED)
}
コード例 #2
0
ファイル: shm_linux.go プロジェクト: jsgilmore/shm
func (buf *sharedBuffer) Advise(offset, length, advice int) error {
	b := buf.Bytes()
	err := checkOffsetLength(b, offset, length)
	if err == nil {
		err = syscall.Madvise(b[offset:offset+length], advice)
	}
	return os.NewSyscallError("shm: madvise", err)
}
コード例 #3
0
func adviseRead(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL|syscall.MADV_WILLNEED)
}
コード例 #4
0
func adviseWrite(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL)
}
コード例 #5
0
ファイル: mmap_linux.go プロジェクト: pombredanne/go-mmap
// Give kernel hints about usage pattern.
func (m Mmap) Advise(advice Advice) error {
	return syscall.Madvise(m, int(advice))
}